preserve. set printback=on. * SIMPLE AND COMPLEX RANDOM ASSIGNMENT IN EXPERIMENTAL DESIGNS Valentim R. Alferes, University of Coimbra (Portugal), 2009. * LS4.sps - Partial counterbalancing (4 treatments; 4 sequences/units). set printback=off. set ovars labels onumbers values tvars labels tnumbers values. set errors=none. 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. data list free/SLS(f8.0). begin data 1 2 3 4 end data. set seed random. compute na1=uniform(1). execute. rank variables=na1(a)/print=no. formats rna1(f8.0). variable labels rna1"Random Permutation". summarize/tables=rna1/format=validlist nocasenum nototal /title='Random Permutation for Selecting One of the Four Standard Latin'+ ' Squares'/cells=none. xsave outfile=file1/keep=SLS na1. execute. data list free /v1(f8.0) v2(f8.0) v3(f8.0) v4(f8.0) SLS(f8.0) line(f8.0). begin data 1 2 3 4 1 1 2 1 4 3 1 2 3 4 2 1 1 3 4 3 1 2 1 4 1 2 3 4 2 1 2 3 4 1 2 2 3 4 1 2 2 3 4 1 2 3 2 4 1 2 3 4 3 1 2 4 1 3 3 2 3 1 4 2 3 3 4 3 2 1 3 4 1 2 3 4 4 1 2 1 4 3 4 2 3 4 1 2 4 3 4 3 2 1 4 4 end data. string SC1 SC2 SC3 SC4 (a8). recode v1 to v4 (1='A') (2='B') (3='C') (4='D') into sc1 to sc4. summarize/tables=sc1 sc2 sc3 sc4 by SLS/format=validlist nocasenum nototal /title='Standard Latin Squares'/cells=none. match files/file=*/table=file1/by SLS. execute. sort cases by na1(a) line(a). sel if ($casenum<5). execute. save outfile=file2. set seed random. compute na2=uniform(1). rank na2(a)/print=no. formats rna2(f8.0). variable labels rna2"Random Permutation". summarize/tables=rna2/format=validlist nocasenum nototal /title='Random Permution for Rows of Square 1'/cells=none. sort cases by na2(a). save outfile=file3. flip variables=v1 to v4. compute na3=uniform(1). rank na3(a)/print=no. formats rna3(f8.0). variable labels rna3"Random Permutation". summarize/tables=rna3/format=validlist nocasenum nototal /title='Random Permution for Columns of Square 2'/cells=none. sort cases by na3(a). string nome (a4). recode rna3 (1='v1') (2='v2') (3='v3') (4='v4') into nome. execute. flip variables=var001 to var004/newname=nome. save outfile=file4. get file=file2. string C1 C2 C3 C4(a8). recode v1 to v4 (1='A') (2='B') (3='C') (4='D') into c1 to c4. execute. summarize/tables=c1 c2 c3 c4/format=validlist nocasenum nototal /title='Square 1 \n Random Selected Standard Latin Square'/cells=none. get file=file3. string C1 C2 C3 C4(a8). recode v1 to v4 (1='A') (2='B') (3='C') (4='D') into c1 to c4. execute. summarize/tables=c1 c2 c3 c4/format=validlist nocasenum nototal /title='Square 2 \n Random Permutation of Square 1 Rows'/cells=none. get file=file4. string C1 C2 C3 C4(a8). recode v1 to v4 (1='A') (2='B') (3='C') (4='D') into c1 to c4. execute. summarize/tables=c1 c2 c3 c4/format=validlist nocasenum nototal /title='Square 3 \n Random Permutation of Square 2 Columns \n Final Latin Square' /cells=none/footnote'If necessary, repeat the syntax for each new set of 4 units'. restore.