Function CategorizeAndStaticize() //This function lets you choose one data wave and one text wave which has entries for which category the entries //in the text wave belong to. It makes new waves for each category it finds and puts the right entries in them. //It also makes a wave with the categories in it, and waves with the average, SD, SEM, and N for each category. //It would be trivial to add other wave analysis to the output. //Notes: SD, SEM calculated even for small Ns, assumes equal number of entries in each input wave (may have any //number of entries in any category), allows you to give a prefix for created waves, will overwrite waves (use prefix wisely), //may operate on target window. String CatList, DataList, CatWaveName, DataWaveName, Cats="", WavePrefix="CAS_" Variable Loop1, NumCats=0, WhichCat DoAlert 2, "Categorize and Calculate Stats: From Target?" if (V_flag==3) //cancel Return -1 elseif (V_flag==2) //no CatList=WaveList("*",";","DIMS:1,TEXT:1") DataList=WaveList("*",";","DIMS:1,TEXT:0") else //yes CatList=WaveList("*",";","DIMS:1,TEXT:1,WIN:") DataList=WaveList("*",";","DIMS:1,TEXT:0,WIN:") endif prompt CatWaveName, "Category Wave", popup, CatList prompt DataWaveName, "Data Wave", popup, DataList prompt WavePrefix, "Wave Name Prefix" DoPrompt "Categorize and Calculate Stats", CatWaveName, DataWaveName, WavePrefix if (V_flag==1) //cancel Return -1 endif Print "Categorize and calculate stats from", CatWaveName, DataWaveName Wave DataWave=$DataWaveName Wave /T CatWave=$CatWaveName for (Loop1=0;Loop1