preserve. set printback=on. * SIMPLE AND COMPLEX RANDOM ASSIGNMENT IN EXPERIMENTAL DESIGNS Valentim R. Alferes, University of Coimbra (Portugal), 2009. * SimpleRand1.sps - Simple Random Assignment (Equal probabilities). set printback=off. set ovars labels onumbers values tvars labels tnumbers values. set errors=none. data list list/nunit(f8.0) ntreat(f8.0). * Enter number of units and number of treatments. begin data 18 3 end data. loop cases=1 to nunit. xsave outfile='%temp%\outf1'/keep=ntreat. end loop. get file='%temp%\outf1'. set rng=mt mtindex=random. compute random=rv.uniform(0,ntreat). compute Treatment=trunc(random)+1. compute Unit=$casenum. formats all(f8.0). oms/select tables/if commands=["summarize"] subtypes=["case processing summary"]/destination viewer=no. summarize/tables=unit treatment/format=validlist nocasenum nototal /title='Simple Random Assignment \n Sorted by Unit'/cells=none. sort cases by treatment(a) unit(a). summarize/tables=unit treatment/format=validlist nocasenum nototal /title='Simple Random Assignment \n Sorted by Treatment'/cells=none. summarize/tables=Unit by treatment/format=nolist total /title='Number of Units per Treatment'/cells=count npct. restore.