The PLAN Procedure

Randomly Assigning Subjects to Treatments

(View the complete code for this example.)

You can use the PLAN procedure to design a completely randomized design. Suppose you have 12 experimental units, and you want to assign one of two treatments to each unit. Use a DATA step to store the unrandomized design in a SAS data set, and then call PROC PLAN to randomize it by specifying one factor with the default type of RANDOM, having 12 levels. The following statements produce Figure 87.3 and Figure 87.4:

title 'Completely Randomized Design';
/* The unrandomized design */
data Unrandomized;
   do Unit=1 to 12;
      if (Unit <= 6) then Treatment=1;
      else                Treatment=2;
      output;
   end;
run;
/* Randomize the design */
proc plan seed=27371;
   factors Unit=12;
   output data=Unrandomized out=Randomized;
run;
proc sort data=Randomized;
   by Unit;
run;
proc print;
run;

Figure 87.3 shows that the 12 levels of the unit factor have been randomly reordered and then lists the new ordering.

Figure 87.3: A Completely Randomized Design for Two Treatments

Completely Randomized Design

The PLAN Procedure

FactorSelectLevelsOrder
Unit1212Random

Unit
851462127391011


After the data set is sorted by the unit variable, the randomized design is displayed (Figure 87.4).

Figure 87.4: A Completely Randomized Design for Two Treatments

Completely Randomized Design

ObsUnitTreatment
111
221
332
441
551
661
772
881
992
10102
11112
12122


You can also generate the plan by using a TREATMENTS statement instead of a DATA step. The following statements generate the same plan.

proc plan seed=27371;
   factors Unit=12;
   treatments Treatment=12 cyclic (1 1 1 1 1 1 2 2 2 2 2 2);
   output out=Randomized;
run;