PROC PLAN

The PLAN procedure constructs experimental designs and generates randomized plans for crossed and nested experiments. You can use it to produce a printed listing, showing the assignment of experimental conditions to experimental units, and/or to produce an output data set. (A similar procedure, PROC FACTEX in SAS/QC constructs more complex factorial designs with fractional replication and planned confounding.)

Specifications

The PLAN procedure is controlled by the statements:
PROC PLAN < SEED=number >
   FACTORS factor-selections < / NOPRINT > ;
   OUTPUT OUT=SAS-data-set
        < DATA=SAS-data-set >
        < factor-value-settings > ;
   TREATMENTS factor-selections ;
The FACTORS statement describes the experimental arrangement of the main experimental units of the design ("plots"). The optional TREATMENTS statement specifies the allocation of treatment factors to the inner-most (most nested) factor in the FACTORS statement.

FACTORS Statement

FACTORS factor-selections < / NOPRINT >;
The form of a factor-selection is
   name=<m OF >n <selection> ...
where:
name
is a valid SAS name which names a factor in the design.
m
is an integer that gives the number of values to be selected. A positive integer m appearing alone after an equal sign produces a random permutation of the integers 1, 2, ..., n.
n
is an integer that gives the number of values to be selected from. The specification m OF n tells PLAN to pick a random sample of m integers (without replacement) from the set of integers 1, 2, ..., n and to arrange the sample randomly.
selection
specifies the method for selecting the m factor level values. ORDERED selects the levels as the integers 1, 2, ..., m in order. RANDOM selects the m levels randomly without replacement from the integers 1, 2, ..., n. CYCLIC selects the levels by cyclically permuting the integers 1, 2, ..., n.

Several factor-selections can be specified in the FACTORS statement. For every integer generated for the first name specified, a permutation is generated for the second name according to the specifications following the second equal sign; for each of the integers generated, a permutation is generated for the second name, the third name, and so forth. For example,

PROC PLAN;
   FACTORS ONE=4 TWO=3;
You can think of factor TWO as being nested within factor ONE, where the levels of factor ONE are to be randomly assigned to 4 units.

Six random permutations of the numbers 1, 2, 3, for instance, can be generated simply by specifying

FACTORS A=6 ORDERED B=3;

Example: Completely randomized 2x3 design

In this example there are two crossed factors, A and B, in a 2x3 design, with four subjects in each cell. PROC PLAN is used to construct the combinations of 2 levels of A, 3 levels of B and 4 levels of REP (replication). In the OUTPUT statement, the CVALS= option is used to assign character labels to the levels of factors A and B. The output data set from PROC PLAN is then randomly arranged in subsequent steps. This is done by adding a uniformly distributed random number to the data set and sorting by REP and RANDOM.
title 'Completely randomized 2 x 3 design, 4 subjects per cell';
proc plan;
   factors a=2 ordered b=3 ordered rep=4 ordered;
   output out=plan a cvals=('A1' 'A2')
                   b cvals=('B1' 'B2' 'B3');
data plan;
   set plan;
   random = uniform(34456761);
proc sort;
   by rep random;
proc print;
The output from PROC PLAN for this design is:
 Procedure PLAN

 Factor    Select  Levels   Order
 ------    ------  ------  -------
 A              2       2  Ordered
 B              3       3  Ordered
 REP            4       4  Ordered

        A        B      REP
 -------- -------- -+-+-+-+

        1        1  1 2 3 4
                 2  1 2 3 4
                 3  1 2 3 4

        2        1  1 2 3 4
                 2  1 2 3 4
                 3  1 2 3 4
The output data set provides a treatment plan for assigning subjects to the experimental conditions. According to this plan, assign subject 1 to treatment A1, B1; subject 2 to A2, B2, etc. The variable RANDOM simply shows that the observations are ordered by RANDOM within each REPlication.
    OBS    A     B     REP     RANDOM

      1    A1    B1     1     0.06231
      2    A2    B2     1     0.26165
      3    A2    B3     1     0.32456
      4    A1    B2     1     0.76251
      5    A2    B1     1     0.80783
      6    A1    B3     1     0.86028
      7    A1    B1     2     0.02399
      8    A2    B2     2     0.39973
      9    A1    B3     2     0.75910
     10    A2    B3     2     0.89131
     11    A2    B1     2     0.90555
     12    A1    B2     2     0.98312
     13    A1    B3     3     0.16927
     14    A2    B1     3     0.33286
     15    A2    B2     3     0.41742
     16    A1    B1     3     0.55691
     17    A2    B3     3     0.56707
     18    A1    B2     3     0.59719
     19    A1    B1     4     0.12746
     20    A2    B3     4     0.22132
     21    A1    B3     4     0.35320
     22    A2    B1     4     0.39337
     23    A2    B2     4     0.43124
     24    A1    B2     4     0.61887

Example: Randomized complete block design

In this example, four subjects form the blocks. Each subject is given five sessions, each with a different task. The SUBJECT and SESSION factors are specified as ORDERED in the FACTORS statement. The TASK factor is specified as RANDOM in the TREATMENTS statement.
title 'Randomized Complete Block design';
proc plan;
   factors subject=4 ordered
           session=5 ordered;
   treatments task=5 random;
   output out=plan;
proc print data=plan;
These statements produce the output:
 Procedure PLAN

 Plot Factors

 Factor    Select  Levels   Order
 ------    ------  ------  -------
 SUBJECT        4       4  Ordered
 SESSION        5       5  Ordered

 Treatment Factors

 Factor    Select  Levels   Order
 ------    ------  ------  -------
 TASK           5       5   Random

  SUBJECT [ SESSION TASK ]
 -------- -----+-----+-----+-----+-----+

        1  [1 4] [2 3] [3 5] [4 1] [5 2]
        2  [1 3] [2 5] [3 1] [4 4] [5 2]
        3  [1 1] [2 2] [3 4] [4 3] [5 5]
        4  [1 4] [2 1] [3 5] [4 2] [5 3]
The output data set produced by PROC PLAN is shown below:
     OBS    SUBJECT    SESSION    TASK

       1       1          1         4
       2       1          2         3
       3       1          3         5
       4       1          4         1
       5       1          5         2
       6       2          1         3
       7       2          2         5
       8       2          3         1
       9       2          4         4
      10       2          5         2
      11       3          1         1
      12       3          2         2
      13       3          3         4
      14       3          4         3
      15       3          5         5
      16       4          1         4
      17       4          2         1
      18       4          3         5
      19       4          4         2
      20       4          5         3

Example: Latin Square Design

A latin square design is based on experimental units that have a row and column block structure, where each treatment appears just once in each row and column. The following example uses the CYCLIC option for a treatment factor TMTS to generate a 4 x 4 latin square. Randomizing a latin square involves randomly permuting the row, column, and treatment values independently. To do this, the RANDOM option is used in the OUTPUT statement.
title 'Latin Square design';
proc plan seed=37430;
   factors    rows=4 ordered cols=4 ordered ;
   treatments tmts=4 cyclic;
   output out=g
     rows cvals=('Day 1' 'Day 2' 'Day 3' 'Day 4') random
     cols cvals=('Lab 1' 'Lab 2' 'Lab 3' 'Lab 4') random
     tmts nvals=(   0      100     250     450  ) random;
run;
proc tabulate;
   class rows cols;
   var   tmts;
   table rows, cols*(tmts*f=6.) / rts=8;
   keylabel sum='    ';
run;
The output from PROC PLAN for this design is:
 Procedure PLAN

 Plot Factors

 Factor    Select  Levels   Order
 ------    ------  ------  -------
 ROWS           4       4  Ordered
 COLS           4       4  Ordered

 Treatment Factors

 Factor    Select  Levels   Order   Initial block / Increment
 ------    ------  ------  -------  -------------------------
 TMTS           4       4   Cyclic  (1 2 3 4) / 1

     ROWS [ COLS TMTS ]
 -------- -----+-----+-----+-----+

        1  [1 1] [2 2] [3 3] [4 4]
        2  [1 2] [2 3] [3 4] [4 1]
        3  [1 3] [2 4] [3 1] [4 2]
        4  [1 4] [2 1] [3 2] [4 3]
PROC TABULATE is used to produce a nicely-formatted table of the design:
       ------------------------------------
       |      |           COLS            |
       |      |---------------------------|
       |      |Lab 1 |Lab 2 |Lab 3 |Lab 4 |
       |      |------+------+------+------|
       |      | TMTS | TMTS | TMTS | TMTS |
       |------+------+------+------+------|
       |ROWS  |      |      |      |      |
       |------|      |      |      |      |
       |Day 1 |     0|   100|   450|   250|
       |------+------+------+------+------|
       |Day 2 |   100|   250|     0|   450|
       |------+------+------+------+------|
       |Day 3 |   250|   450|   100|     0|
       |------+------+------+------+------|
       |Day 4 |   450|     0|   250|   100|
       ------------------------------------