Chapter Contents Previous Next
 The PLAN Procedure

## Output Data Sets

To understand how PROC PLAN creates output data sets, you need to look at how the procedure represents a plan. A plan is a list of values for all the factors, the values being chosen according to the factor-selection requests you specify. For example, consider the plan produced by the following statements:

```   proc plan seed=12345;
factors a=3 b=2;
run;
```

The plan as displayed by PROC PLAN is shown in Figure 50.5.

 The PLAN Procedure

 Factor Select Levels Order a 3 3 Random b 2 2 Random

 a b 2 2 1 1 1 2 3 2 1

Figure 50.5: A Simple Plan

The first cell of the plan has a=2 and b=2, the second a=2 and b=1, the third a=1 and b=1, and so on. If you output the plan to a data set with the OUTPUT statement, by default the output data set contains a numeric variable with that factor's name; the values of this numeric variable are the numbers of the successive levels selected for the factor in the plan. For example, the following statements produce Figure 50.6.

```   proc plan seed=12345;
factors a=3 b=2;
output out=out;
proc print data=out;
run;
```

 Obs a b 1 2 2 2 2 1 3 1 1 4 1 2 5 3 2 6 3 1

Figure 50.6: Output Data Set from Simple Plan

Alternatively, you can specify the values that are output for a factor with the CVALS= or NVALS= option. Also, you can specify that the internal values be associated with the output values in a random order with the RANDOM option. See the "OUTPUT Statement" section.

If you also specify an input data set (DATA=), each factor is associated with a variable in the DATA= data set. This occurs either implicitly by the factor and variable having the same name or explicitly as described in the specifications for the OUTPUT statement. In this case, the values of the variables corresponding to the factors are first read and then interpreted as describing the position of a cell in the plan. Then the respective values taken by the factors at that position are assigned to the variables in the OUT= data set. For example, consider the data set defined by the following statements.

```   data in;
input a b;
datalines;
1 1
2 1
3 1
;
```

Suppose you specify this data set as an input data set for the OUTPUT statement.

```   proc plan seed=12345;
factors a=3 b=2;
output out=out data=in;
proc print data=out;
run;
```

PROC PLAN interprets the first observation as referring to the cell in the first row and column of the plan, since a=1 and b=1; likewise, the second observation is interpreted as the cell in the second row and first column, and the third observation as the cell in the third row and first column. In the output data set a and b have the values they have in the plan at these positions, as shown in Figure 50.7.

 Obs a b 1 2 2 2 1 1 3 3 2

Figure 50.7: Output Form of Input Data Set from Simple Plan

When the factors are random, this has the effect of randomizing the input data set in the same manner as the plan produced (see the "Randomizing Designs" section and the "Randomly Assigning Subjects to Treatments" section).

 Chapter Contents Previous Next Top