preserve. set printback=on. * SIMPLE AND COMPLEX RANDOM ASSIGNMENT IN EXPERIMENTAL DESIGN (Version 2.0) Valentim R. Alferes, University of Coimbra (Portugal), 2014. * BETWEEN-SUBJECTS DESIGNS. * Program: SRA-es.sps Method 3: Simple Random Assignment (Forced equal sizes) Completely Randomized Designs (Designs 1, 7, 14, 18, and 20). set printback=off. set ovars labels onumbers values tvars labels tnumbers values. set olang=English small=0 errors=none decimal=dot. data list list/nunit(f8.0) ntreat(f8.0). /* User's Specifications /* * Enter number of units per experiment and number of treatments. begin data 20 3 end data. save outfile='%temp%\fout0'. loop tperm=1 to ntreat. xsave outfile='%temp%\fout1'. end loop. get file='%temp%\fout1'. set rng=mt mtindex=random. compute rnperm=rv.uniform(0,1). execute. sort cases by rnperm(a). compute idperm=$casenum. execute. variable labels tperm"Random Permutation". save outfile='%temp%\fout2'. compute modsel=mod(nunit,ntreat). execute. sel if(idperm<=modsel). execute. save outfile='%temp%\fout3'/keep idperm tperm. get file='%temp%\fout0'. loop x=1 to nunit. xsave outfile='%temp%\fout4'/keep=ntreat nunit. end loop. get file='%temp%\fout4'. compute x=$casenum. compute Treatment=mod((x-1),ntreat)+1. if(x>nunit-mod(nunit,ntreat)) lrc=1. if(x<=nunit-mod(nunit,ntreat)) lrc=0. execute. rank variables=x(a) by lrc/rank/print=no/ties=condense. if(lrc=1) idperm=rx. execute. match files/file=*/file='%temp%\fout3'/by idperm . execute. if(lrc=1) treatment=tperm. execute. sort cases by treatment(a) x(a). set rng=mt mtindex=random. compute rn=rv.uniform(0,1). execute. sort cases by rn(a). compute Unit=$casenum. execute. formats all(f8.0). save outfile='%temp%\fout0'. oms/select tables/if commands=["summarize"] subtypes=["case processing summary"]/destination viewer=no. oms/select tables/if commands=["crosstabs"] subtypes=["case processing summary"]/destination viewer=no. variable labels lrc"Last Replication Correction". value labels lrc 0"No" 1"Yes". get file='%temp%\fout2'. formats all(f8.0). summarize/tables=tperm/format=list nocasenum nototal /title='Last Replication Correction'/cells=none/footnote "Random Permutation = Order of treatments in the last replication "+ "when the Last Replication Correction is applied (see note at the "+ "botton of the output).". get file='%temp%\fout0'. summarize/tables=unit treatment/format=validlist nocasenum nototal /title='Simple Random Assignment \n Sorted by Unit \n'+ '(Sequential Assignment)'/cells=none. sort cases by treatment(a) unit(a). summarize/tables=treatment unit/format=validlist nocasenum nototal /title='Simple Random Assignment \n Sorted by Treatment/Unit \n'+ '(Captive Assignment)'/cells=none. summarize/tables=unit by treatment/format=nolist total /title='Number of Units per Treatment'/cells=count npct/footnote "If the number of units per experiment specified by the user is not "+ "a multiple of the number of treatments, Last Replication Correction "+ "is applied [see Procedure (c), Alferes, 2012, p. 27].". save outfile='%userprofile%\desktop\FinalDesign.sav'/keep=Unit Treatment. get file='%userprofile%\desktop\FinalDesign.sav'. erase file='%temp%\fout0'. erase file='%temp%\fout1'. erase file='%temp%\fout2'. erase file='%temp%\fout3'. erase file='%temp%\fout4'. restore.