preserve. set printback=on. * SIMPLE AND COMPLEX RANDOM ASSIGNMENT IN EXPERIMENTAL DESIGN (Version 2.0) Valentim R. Alferes, University of Coimbra (Portugal), 2013. * WITHIN-SUBJECTS DESIGNS. * Program: RC-ro.sps Method 14: Random Counterbalancing Design 6N: Repeated Measures Randomized Block Design. set printback=off. set ovars labels onumbers values tvars labels tnumbers labels. set olang=English small=0 errors=none decimal=dot. new file. input program. /* User's Specifications /* * Replace "?" with the number of treatments. loop t=1 to ?. end case. end loop. end file. end input program. execute. set rng=mt mtindex=random. /* User Specifications /* * Replace "?" with the number of experimental units. do repeat n=n_1 to n_?. compute n=rv.uniform(-1,0). end repeat. execute. compute x=1. execute. aggregate/outfile=*mode=addvariables/break=x/nt=max(t). formats nt(f8.0). variable labels nt"Number of Treatments". oms/select tables/if commands=["summarize"] subtypes=["case processing summary"]/destination viewer=no. summarize/tables=nt/format=list nocasenum nototal limit=1 /title="User's Specifications"/cells=none. delete variables t nt x. rank all(a)/rank/print=no/ties=condense. compute myname=$casenum. execute. string yourname(a8). recode myname (sysmis='P_') (else='P_') into yourname. execute. string finalname(A8). compute finalname=concat(rtrim(yourname),ltrim(string(myname,f5))). execute. delete variables myname yourname. set results=no. flip all/newname=finalname. set results=yes. sel if (p_1>=1). execute. compute x=1. execute. aggregate/outfile=*mode=addvariables/break=x/y=max(p_1)/nut=n. formats nut(f8.0). variable labels nut"Number of Experimental Units". summarize/tables=nut/format=list nocasenum nototal limit=1 /title="User's Specifications"/cells=none. delete variables case_lbl x y nut. value labels all 1'A' 2'B' 3'C' 4'D' 5'E' 6'F' 7'G' 8'H' 9'I' 10'J' 11'K' 12'L' 13'M' 14'N' 15'O' 16'P' 17'Q' 18'R' 19'S' 20'T' 21'U' 22'V' 23'W' 24'X' 25'Y' 26'Z'. compute Unit=$casenum. execute. formats all(f8.0). summarize/tables=Unit all/format=list nocasenum nototal /title='Method 14: Random Counterbalancing \n Final '+ 'Randomization Sorted by Unit'/cells=none./footnote 'P = Period'. save outfile='%userprofile%\desktop\FinalDesign.sav'/keep unit all. get file='%userprofile%\desktop\FinalDesign.sav'. restore.