32
Chapter 50 The PLAN Procedure Chapter Table of Contents OVERVIEW ................................... 2661 GETTING STARTED .............................. 2662 Three Replications with Four Factors ...................... 2662 Randomly Assigning Subjects to Treatments .................. 2663 SYNTAX ..................................... 2665 PROC PLAN Statement ............................ 2665 FACTORS Statement .............................. 2666 OUTPUT Statement .............................. 2669 TREATMENTS Statement ........................... 2672 DETAILS ..................................... 2673 Using PROC PLAN Interactively ........................ 2673 Output Data Sets ................................ 2673 Specifying Factor Structures .......................... 2675 Randomizing Designs .............................. 2678 Displayed Output ................................ 2678 ODS Table Names ............................... 2678 EXAMPLES ................................... 2679 Example 50.2 A Split-Plot Design ....................... 2679 Example 50.3 A Hierarchical Design ...................... 2680 Example 50.3 An Incomplete Block Design .................. 2681 Example 50.4 A Latin Square Design ..................... 2683 Example 50.5 A Generalized Cyclic Incomplete Block Design ........ 2684 Example 50.6 Permutations and Combinations ................. 2685 REFERENCES .................................. 2689

The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

Embed Size (px)

Citation preview

Page 1: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

Chapter 50The PLAN Procedure

Chapter Table of Contents

OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2661

GETTING STARTED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2662Three Replications with Four Factors . . . . . . . . . . . . . . . . . . . . . .2662Randomly Assigning Subjects to Treatments . .. . . . . . . . . . . . . . . .2663

SYNTAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2665PROC PLAN Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . .2665FACTORS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2666OUTPUT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2669TREATMENTS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . .2672

DETAILS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2673Using PROC PLAN Interactively . . . . . . . . . . . . . . . . . . . . . . . .2673Output Data Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2673Specifying Factor Structures . . . . . . . . . . . . . . . . . . . . . . . . . .2675Randomizing Designs . . .. . . . . . . . . . . . . . . . . . . . . . . . . . .2678Displayed Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2678ODS Table Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2678

EXAMPLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2679Example 50.2 A Split-Plot Design .. . . . . . . . . . . . . . . . . . . . . .2679Example 50.3 A Hierarchical Design . . . . . . . . . . . . . . . . . . . . . .2680Example 50.3 An Incomplete Block Design . . . . . . . . . . . . . . . . . .2681Example 50.4 A Latin Square Design . . . . . . . . . . . . . . . . . . . . .2683Example 50.5 A Generalized Cyclic Incomplete Block Design . . . . . . . .2684Example 50.6 Permutations and Combinations . . . . . . . . . . . . . . . . .2685

REFERENCES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2689

Page 2: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2660 � Chapter 50. The PLAN Procedure

SAS OnlineDoc: Version 8

Page 3: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

Chapter 50The PLAN Procedure

Overview

The PLAN procedure constructs designs and randomizes plans for factorial exper-iments, especially nested and crossed experiments and randomized block designs.PROC PLAN can also be used for generating lists of permutations and combinationsof numbers. The PLAN procedure can construct the following types of experimentaldesigns:

� full factorials, with and without randomization

� certain balanced and partially balanced incomplete block designs

� generalized cyclic incomplete block designs

� Latin square designs

For other kinds of experimental designs, especially fractional factorial, response sur-face, and orthogonal array designs, refer to the FACTEX and OPTEX procedures andthe ADX Interface in SAS/QC software.

PROC PLAN generates designs by first generating a selection of the levels for the firstfactor. Then, for the second factor, PROC PLAN generates a selection of its levelsfor each level of the first factor. In general, for a given factor, the PLAN proceduregenerates a selection of its levels for all combinations of levels for the factors thatprecede it. The selection can be done in five different ways:

� randomized selection, for which the levels are returned in a random order

� ordered selection, for which the levels are returned in a standard order everytime a selection is generated

� cyclic selection, for which the levels returned are computed by cyclically per-muting the levels of the previous selection

� permuted selection, for which the levels are a permutation of the integers1; : : :; n

� combination selection, for which them levels are selected as a combination ofthe integers1; : : :; n takenm at a time

Page 4: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2662 � Chapter 50. The PLAN Procedure

The randomized selection method can be used to generate randomized plans. Also,by appropriate use of cyclic selection, any of the designs in the very wide class ofgeneralized cyclic block designs (Jarrett and Hall 1978) can be generated.

There is no limit to the depth to which the different factors can be nested, and anynumber of randomized plans can be generated.

You can also declare a list of factors to be selected simultaneously with the lowest(that is, the most nested) factor. The levels of the factors in this list can be seenas constituting the treatment to be applied to the cells of the design. For this reason,factors in this list are calledtreatments. With this list, you can generate and randomizeplans in one run of PROC PLAN.

Getting Started

Three Replications with Four Factors

Suppose you want to determine if the order in which four drugs are given affectsthe response of a subject. If you have only three subjects to test, you can use thefollowing statements to design the experiment.

proc plan seed=27371;factors Replicate=3 ordered Drug=4;

run;

These statements produce a design with three replicates of the four levels of the factorDrug arranged in random order. The three levels ofReplicate are arranged in order,as shown in Figure 50.1

The PLAN Procedure

Factor Select Levels Order

Replicate 3 3 OrderedDrug 4 4 Random

Replicate --Drug-

1 3 2 4 12 1 2 4 33 4 1 2 3

Figure 50.1. Three Replications and Four Factors

You may also want to apply one of four different treatments to each cell of this plan(for example, applying different amounts of each drug). The following statementscreate the output shown in Figure 50.2

factors Replicate=3 ordered Drug=4;treatments Treatment=4;

run;

SAS OnlineDoc: Version 8

Page 5: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

Randomly Assigning Subjects to Treatments � 2663

The PLAN Procedure

Plot Factors

Factor Select Levels Order

Replicate 3 3 OrderedDrug 4 4 Random

Treatment Factors

Factor Select Levels Order

Treatment 4 4 Random

Replicate --Drug- --Treatment--

1 3 1 2 4 2 1 3 42 4 3 2 1 4 1 2 33 3 2 4 1 1 4 2 3

Figure 50.2. Using the TREATMENTS Statement

Randomly Assigning Subjects to Treatments

You can use the PLAN procedure to design a completely randomized design. Supposeyou have 12 experimental units, and want to assign one of two treatments to eachunit. Use a DATA step to store the unrandomized design in a SAS data set, then callPROC PLAN to randomize it by specifying one RANDOM factor of 12 levels. Thefollowing statements produce Figure 50.3 and Figure 50.4:

title ’Completely Randomized Design’;/* The unrandomized design */data a;

do unit=1 to 12;if (unit <= 6) then treat=1;else treat=2;output;

end;run;

/* Randomize the design */proc plan seed=27371;

factors unit=12;output data=a out=b;

run;

proc sort data=b;by unit;

proc print;run;

Figure 50.3 shows that the 12 levels of theunit factor have been randomly reorderedand then lists the new ordering.

SAS OnlineDoc: Version 8

Page 6: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2664 � Chapter 50. The PLAN Procedure

Completely Randomized Design

The PLAN Procedure

Factor Select Levels Order

unit 12 12 Random

----------------unit---------------

8 5 1 4 6 2 12 7 3 9 10 11

Figure 50.3. A Completely Randomized Design for Two Treatments

After the data is sorted by theunit variable, the randomized design is displayed inFigure 50.4.

Completely Randomized Design

Obs unit treat

1 1 12 2 13 3 24 4 15 5 16 6 17 7 28 8 19 9 2

10 10 211 11 212 12 2

Figure 50.4. A Completely Randomized Design for Two Treatments

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

proc plan seed=27371;factors unit=12;treatments treat=12 cyclic (1 1 1 1 1 1 2 2 2 2 2 2);output out=b;

run;

SAS OnlineDoc: Version 8

Page 7: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

PROC PLAN Statement � 2665

Syntax

The following statements are available in PROC PLAN.

PROC PLAN < options > ;FACTORS factor-selections < / NOPRINT > ;

OUTPUT OUT=SAS-data-set < factor-value-settings > ;TREATMENTS factor-selections ;

To use PROC PLAN, you need to specify the PROC PLAN statement and at least oneFACTORS statement before the first RUN statement. The TREATMENTS statement,OUTPUT statement, and additional FACTORS statements can appear either beforethe first RUN statement or after it. The rest of this section gives detailed syntaxinformation for each of the statements, beginning with the PROC PLAN statement.The remaining statements are described in alphabetical order.

You can use PROC PLAN interactively by specifying multiple groups of statements,separated by RUN statements. For details, see the “Using PROC PLAN Interactively”section on page 2673.

PROC PLAN Statement

PROC PLAN < options > ;

The PROC PLAN statement starts the PLAN procedure and, optionally, specifies arandom number seed or a default method for selecting levels of factors. By default,the procedure uses a random number seed generated from reading the time of dayfrom the computer’s clock and randomly selects levels of factors. These defaults canbe modified with the SEED= and ORDERED options, respectively. Unlike manySAS/STAT procedures, the PLAN procedure does not have a DATA= option in thePROC statement; in this procedure, both the input and output data sets are specifiedin the OUTPUT statement.

You can specify the following options in the PROC PLAN statement:

SEED=numberspecifies a positive integer less than231 � 1. PROC PLAN uses the value of theSEED= option to start the pseudo-random number generator for selecting factor levelsrandomly. The default is a value generated from reading the time of day from thecomputer’s clock.

ORDEREDselects the levels of the factor as the integers1; 2; : : : ;m; in order. For more de-tail, see the “Selection-Types” section on page 2666 and see the “Specifying FactorStructures” section on page 2675.

SAS OnlineDoc: Version 8

Page 8: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2666 � Chapter 50. The PLAN Procedure

FACTORS Statement

FACTORS factor-selections < / NOPRINT > ;

The FACTORS statement specifies the factors of the plan and generates the plan.Taken together, thefactor-selectionsspecify the plan to be generated; more than onefactor-selectionrequest can be used in a FACTORS statement. The form of afactor-selectionis

name=m < OF n > < selection-type >

where

name is a valid SAS name. This gives the name of a factor in the design.

m is a positive integer that gives the number of values to be selected. Ifn is specified, the value ofm must be less than or equal ton.

n is a positive integer that gives the number of values to be selectedfrom.

selection-type specifies one of five methods for selectingm values. Possible val-ues are COMB, CYCLIC, ORDERED, PERM or RANDOM. TheCYCLIC selection-typehas additional optional specifications thatenable you to specify an initial block of numbers to be cyclically per-muted and an increment used to permute the numbers. By default,theselection-typeis RANDOM, unless you use the ORDERED op-tion in the PROC PLAN statement. In this case, the defaultselection-typeis ORDERED. For details, see the following section, “Selection-Types”; for examples, see the “Syntax Examples” section.

The following option can appear in the FACTORS statement after the slash:

NOPRINTsuppresses the display of the plan. This is particularly useful when you require onlyan output data set. Note that this option temporarily disables the Output DeliverySystem (ODS); see Chapter 15, “Using the Output Delivery System,” for more infor-mation.

Selection-TypesPROC PLAN interpretsselection-typeas follows:

RANDOM selects them levels of the factor randomly without replacement fromthe integers1; 2; : : : ; n. Or, if n is not specified, RANDOM selectslevels by randomly ordering the integers1; 2; : : : ;m.

ORDERED selects the levels of the factor as the integers1; 2; : : : ;m, in that order.

SAS OnlineDoc: Version 8

Page 9: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

FACTORS Statement � 2667

PERM selects them levels of the factor as a permutation of the integers1; : : : m according to an algorithm that cycles through allm! permu-tations. The permutations are produced in a sorted standard order; seeExample 50.6 on page 2685.

COMB selects them levels of the factor as a combination of the integers1; : : : ; n takenm at a time, according to an algorithm that cyclesthrough alln!=(m!(n � m)!) combinations. The combinations areproduced in a sorted standard order; see Example 50.6 on page 2685.

CYCLIC <(initial-block) >< increment>selects the levels of the factor by cyclically permuting the integers1; 2; : : : ; n. Wrapping occurs atm if n is not specified, and atn if nis specified. Additional optional specifications are as follows:

With theselection-typeCYCLIC, you can optionally specify aninitial-block and anincrement. The initial-block must be specified withinparentheses, and it specifies the block of numbers to permute. The firstpermutation is the block you specify, the second is the block permutedby 1 (or by theincrementyou specify), and so on. By default, theinitial-block is the integers1; 2; : : : ;m. If you specify aninitial-block,it must havem values. Values specified in theinitial-block do not haveto be given in increasing order.

The incrementspecifies the increment by which to permute the blockof numbers. By default, theincrementis 1.

Syntax ExamplesThis section gives some simple syntax examples. For more complex examples anddetails on how to generate various designs, see the “Specifying Factor Structures”section on page 2675. The examples in this section assume that you use the defaultrandom selection method and do not use the ORDERED option in the PROC PLANstatement.

The following specification generates a random permutation of the numbers 1, 2, 3,4, and 5.

factors A=5;

The following specification generates a random permutation of 5 of the integers from1 to 8, selected without replacement.

factors A=5 of 8;

Adding the ORDEREDselection-typeto the two previous specifications generates anordered list of the integers 1 to 5. The following specification cyclically permutes theintegers 1, 2, 3, and 4.

factors A=4 cyclic;

SAS OnlineDoc: Version 8

Page 10: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2668 � Chapter 50. The PLAN Procedure

Since this simple request generates only one permutation of the numbers, the pro-cedure generates an ordered list of the integers 1 to 4. The following specificationcyclically permutes the integers 5 to 8.

factors A=4 of 8 cyclic (5 6 7 8);

In this case, since only one permutation is performed, the procedure generates anordered list of the integers 5 to 8. The following specification produces an orderedlist for A, with values 1 and 2.

factors A=2 ordered B=4 of 8 cyclic (5 6 7 8) 2;

The associated factor levels forB are 5, 6, 7, 8 for level 1 ofA; and 7, 8, 1, 2 for level2 of A.

Handling More than One Factor-SelectionFor cases with more than onefactor-selectionin the same FACTORS statement,PROC PLAN constructs the design as follows:

1. PROC PLAN first generates levels for the firstfactor-selection. These levelsare permutations of integers (1, 2, and so on) appropriate for the selection typechosen. If you do not specify a selection type, PROC PLAN uses the default(RANDOM); if you specify the ORDERED option in the PROC PLAN state-ment, the procedure uses ORDERED as the default selection type.

2. For every integer generated for the firstfactor-selection, levels are generatedfor the secondfactor-selection. These levels are generated according to thespecifications following the second equal sign.

3. This process is repeated until levels for allfactor-selectionshave been gener-ated.

The following statements give an example of generating a design with two randomfactors:

proc plan;factors One=4 Two=3;

run;

The procedure first generates a random permutation of the integers 1 to 4 and then,for each of these, generates a random permutation of the integers 1 to 3. You canthink of factor Two as being nested within factorOne, where the levels of factorOne are to be randomly assigned to 4 units.

SAS OnlineDoc: Version 8

Page 11: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

OUTPUT Statement � 2669

As another example, six random permutations of the numbers 1, 2, 3 can be generatedby specifying

proc plan;factors a=6 ordered b=3;

run;

OUTPUT Statement

OUTPUT OUT=SAS-data-set < DATA=SAS-data-set >< factor-value-settings > ;

The OUTPUT statement applies only to the last plan generated. If you use PROCPLAN interactively, the OUTPUT statement for a given plan must be immediatelypreceded by the FACTORS statement (and the TREATMENTS statement, if appro-priate) for the plan. See the “Output Data Sets” section on page 2673 for more in-formation on how output data sets are constructed. You can specify the followingoptions in the OUTPUT statement:

OUT=SAS-data-setDATA=SAS-data-set

You can use the OUTPUT statement both to output the last plan generated and to usethe last plan generated to randomize another SAS data set.

When you specify only the OUT= option in the OUTPUT statement, PROC PLANsaves the last plan generated to the specified data set. The output data set containsone variable for each factor in the plan and one observation for each cell in the plan.The value of a variable in a given observation is the level of the corresponding factorfor that cell. The OUT= option is required.

When you specify both the DATA= and OUT= options in the OUTPUT statement,then PROC PLAN uses the last plan generated to randomize the input data set(DATA=), saving the results to the output data set (OUT=). The output data set hasthe same form as the input data set but has modified values for the variables thatcorrespond to factors (see the “Output Data Sets” section on page 2673 for details).Values for variables not corresponding to factors are transferred without change.

factor-value-settingsspecify the values input or output for the factors in the design. The form forfactor-value-settingsis different when only an OUT= data set is specified and when bothOUT= and DATA= data sets are specified. Both forms are discussed in the followingsection.

SAS OnlineDoc: Version 8

Page 12: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2670 � Chapter 50. The PLAN Procedure

Factor-Value-Settings with Only an OUT= Data SetWhen you specify only an OUT= data set, the form for eachfactor-value-settingspecification is one of the following:

factor-name < NVALS= list-of-n-numbers > < ORDERED | RANDOM >

or

factor-name < CVALS= list-of-n-strings > < ORDERED | RANDOM >

where

factor-name is a factor in the last FACTORS statement preceding the OUTPUTstatement.

NVALS= listsn numeric values for the factor. By default, the procedure usesNVALS=(1 2 3 � � �n).

CVALS= lists n character strings for the factor. Each string can have up to40 characters, and each string must be enclosed in quotes.Warn-ing: When you use the CVALS= option, the variable created in theoutput data set has a length equal to the length of the longest stringgiven as a value; shorter strings are padded with trailing blanks. Forexample, the values output for the first level of a two-level factorwith the following two different specifications are not the same.

CVALS=(’String 1’ "String 2")

CVALS=(’String 1’ "A longer string")

The value output with the second specification is ’String 1’ fol-lowed by seven blanks. In order to match two such values (for ex-ample, when merging two plans), you must use the TRIM functionin the DATA step (refer toSAS Language Reference: Dictionary).

ORDERED | RANDOM specifies how values (those given with the NVALS= orCVALS= option, or the default values) are associated with the lev-els of a factor (the integers1; 2; : : : ; n). The default associationtype is ORDERED, for which the first value specified is output fora factor level setting of 1, the second value specified is output fora level of 2, and so on. You can also specify an association type ofRANDOM, for which the levels are associated with the values ina random order. Specifying RANDOM is useful for randomizingcrossed experiments (see the “Randomizing Designs” section onpage 2678).

SAS OnlineDoc: Version 8

Page 13: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

OUTPUT Statement � 2671

The following statements give an example of using the OUTPUT statement with onlyan OUT= data set and with both the NVALS= and CVALS= specifications.

proc plan;factors a=6 ordered b=3;output out=design a nvals=(10 to 60 by 10)

b cvals=(’HSX’ ’SB2’ ’DNY’);run;

The DESIGN data set contains two variables,a andb. The values of the variablea are 10 when factora equals 1, 20 when factora equals 2, and so on. Values ofthe variableb are ‘HSX’ when factorb equals 1, ‘SB2’ when factorb equals 2, and‘DNY’ when factor b equals 3.

Factor-Value-Settings with OUT= and DATA= Data SetsIf you specify an input data set with DATA=, then PROC PLAN assumes that eachfactor in the last plan generated corresponds to a variable in the input set. If thevariable name is different from the name of the factor to which it corresponds, thetwo can be associated in the values specification by

input-variable-name = factor-name

Then, the NVALS= or CVALS= specification can be used. The values given byNVALS= or CVALS= specify the input values as well as the output values for thecorresponding variable.

Since the procedure assumes that the collection of input factor values constitutesa plan position description (see the “Output Data Sets” section on page 2673), thevalues must correspond to integers less than or equal tom, the number of valuesselected for the associated factor. If any input values do not correspond, then thecollection does not define a plan position, and the corresponding observation is outputwithout changing the values of any of the factor variables.

The following statements demonstrate the use of factor-value settings. The inputSAS data seta contains variablesBlock andPlot, which are renamedDay andHour,respectively.

proc plan;factors Day=7 Hour=6;output data=a out=b

Block = Day cvals=(’Mon’ ’Tue’ ’Wed’ ’Thu’’Fri’ ’Sat’ ’Sun’ )

Plot = Hour;run;

For another example of using both a DATA= and OUT= data set, see the “RandomlyAssigning Subjects to Treatments” section on page 2663.

SAS OnlineDoc: Version 8

Page 14: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2672 � Chapter 50. The PLAN Procedure

TREATMENTS Statement

TREATMENTS factor-selections ;

The TREATMENTS statement specifies thetreatmentsof the plan to generate, butit does not generate a plan. If you supply several FACTORS and TREATMENTSstatements before the first RUN statement, the procedure uses only the last TREAT-MENTS specification and applies it to the plans generated by each of the FACTORSstatements. The TREATMENTS statement has the same form as the FACTORS state-ment. The individualfactor-selectionsalso have the same form as in the FACTORSstatement:

name=m < OF n > < selection-type >

The procedure generates eachtreatmentsimultaneously with the lowest (that is, themost nested) factor in the last FACTORS statement. Them value for eachtreatmentmust be at least as large as them for the most-nested factor.

The following statements give an example of using both a FACTORS and a TREAT-MENTS statement. First the FACTORS statement sets up the rows and columns ofa 3 � 3 square (factorsr andc). Then, the TREATMENTS statement augments thesquare with two cyclic treatments. The resulting design is a3 � 3 Graeco-Latinsquare, a type of design useful in main-effects factorial experiments.

proc plan;factors r=3 ordered c=3 ordered;treatments a=3 cyclic

b=3 cyclic 2;run;

The resulting Graeco-Latin square design is reproduced below. Notice how the valuesof r andc are ordered (1, 2, 3) as requested.

r --c-- --a-- --b--

1 1 2 3 1 2 3 1 2 32 1 2 3 2 3 1 3 1 23 1 2 3 3 1 2 2 3 1

SAS OnlineDoc: Version 8

Page 15: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

Output Data Sets � 2673

Details

Using PROC PLAN Interactively

After specifying a design with a FACTORS statement and running PROC PLAN witha RUN statement, you can generate additional plans and output data sets withoutreinvoking PROC PLAN.

In PROC PLAN, all statements can be used interactively. You can execute statementssingly or in groups by following the single statement or group of statements with aRUN statement.

If you use PROC PLAN interactively, you can end the procedure with a DATA step,another PROC step, an ENDSAS statement, or a QUIT statement. The syntax of thisstatement is

quit;

When you use PROC PLAN interactively, additional RUN statements do not end theprocedure but tell PROC PLAN to execute additional statements.

Output Data Sets

To understand how PROC PLAN creates output data sets, you need to look at howthe procedure represents a plan. A plan is a list of values for all the factors, the valuesbeing 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 Randomb 2 2 Random

a -b-

2 2 11 1 23 2 1

Figure 50.5. A Simple Plan

SAS OnlineDoc: Version 8

Page 16: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2674 � Chapter 50. The PLAN Procedure

The first cell of the plan hasa=2 andb=2, the seconda=2 andb=1, the thirda=1andb=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; thevalues of this numeric variable are the numbers of the successive levels selected forthe 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 22 2 13 1 14 1 25 3 26 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 withthe output values in a random order with the RANDOM option. See the “OUTPUTStatement” section on page 2669.

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

data in;input a b;datalines;

1 12 13 1;

SAS OnlineDoc: Version 8

Page 17: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

Specifying Factor Structures � 2675

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 andcolumn of the plan, sincea=1 andb=1; likewise, the second observation is interpretedas the cell in the second row and first column, and the third observation as the cellin the third row and first column. In the output data seta andb have the values theyhave in the plan at these positions, as shown in Figure 50.7.

Obs a b

1 2 22 1 13 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 setin the same manner as the plan produced (see the “Randomizing Designs” sectionon page 2678 and the “Randomly Assigning Subjects to Treatments” section onpage 2663).

Specifying Factor Structures

By appropriately combining features of the PLAN procedure, you can construct anextensive set of designs. The basic tools are thefactor-selections, which are usedin the FACTORS and TREATMENTS statements. Table 50.1 summarizes how theprocedure interprets variousfactor-selections(assuming that the ORDERED optionis not specified in the PROC PLAN statement).

Table 50.1. Factor Selection Interpretation

Form ofRequest Interpretation Example Resultsname=m produce a random per-

mutation of the integers1; 2; : : : ;m.

t=15 lists a random order-ing of the numbers1; 2; : : : ; 15.

name=mcyclic

cyclically permute theintegers1; 2; : : : ;m.

t=5 cyclic selects the integers 1 to5. On the next iter-ation, selects 2,3,4,5,1;then 3,4,5,1,2; and so on.

SAS OnlineDoc: Version 8

Page 18: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2676 � Chapter 50. The PLAN Procedure

Table 50.1. (continued)

Form ofRequest Interpretation Example Resultsname=m of n choose a random sample

of m integers (with-out replacement) fromthe set of integers1; 2; : : : ; n.

t=5 of 15 lists a random selectionof 5 numbers from 1 to15. First, the proce-dure selects 5 numbersand then arranges themin random order.

name=m of nordered

has the same effect asname=m ordered.

t=5 of 15

ordered

lists the integers 1 to 5 inincreasing order (sameas t=5 ordered).

name=m of ncyclic

permute m of the nintegers.

t=5 of 30

cyclic

selects the integers 1 to5. On the next iter-ation, selects 2,3,4,5,6;then 3,4,5,6,7; and soon. The 30th iteration30,1,2,3,4; the 31st iter-ation produces 1,2,3,4,5;and so on.

name=mperm

produce a list of all per-mutations ofm integers.

t=5 perm lists the integers1,2,3,4,5 on the firstiteration; on the secondlists 1,2,3,5,4; and onthe 119th iteration lists5,4,3,1,2; and on the last(120th) lists 5,4,3,2,1.

name=m of ncomb

choose combinationsof m integers from nintegers.

t=3 of 5

comb

lists all combinations of5 choose 3 integers. Thefirst iteration is 1,2,3; thesecond is 1,2,4; the thirdis 1,2,5; and so on untilthe last iteration 3,4,5.

name=m of ncyclic(initial-block)

permutem of the n in-tegers, starting with thevalues specified in theinitial-block.

t=4 of 30

cyclic

(2 10 15 18)

selects the integers2,10,15,18. On thenext iteration, se-lects 3,11,16,19; then4,12,17,20; and so on.The thirteenth iterationis 14,22,27,30; thefourteenth iteration is15,23,28,1; and so on.

SAS OnlineDoc: Version 8

Page 19: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

Specifying Factor Structures � 2677

Table 50.1. (continued)

Form ofRequest Interpretation Example Resultsname=m of ncyclic(initial-block)increment

permutem of the n in-tegers. Start with thevalues specified in theinitial-block, then addthe increment to eachvalue.

t=4 of 30

cyclic

(2 10 15 18)

2

selects the integers2,10,15,18. On thenext iteration, se-lects 4,12,17,20; then6,14,19,22; and so on.The wrap occurs atthe eighth iteration.The eighth iteration is16,24,29,2; and so on.

In Table 50.1, in order for more than one iteration to appear in the plan, anothername=jfactor selection (withj > 1) must precede the example factor selection. Forexample, the following statements produce six of the iterations described in the lastentry of Table 50.1.

proc plan;factors c=6 ordered t=4 of 30 cyclic (2 10 15 18) 2;

run;

The following statements create a randomized complete block design and output thedesign to a data set.

proc plan ordered;factors blocks=3 cell=5;treatments t=5 random;output out=rcdb;

run;

Table 50.2 lists other kinds of experiment designs that can be constructed by PROCPLAN, along with section and page references for them in this chapter.

Table 50.2. Experimental Design Examples

Design Page NumberCompletely randomized design page 2663Split-plot design page 2679Nested design page 2680Latin square design page 2683Generalized cyclic incomplete block designpage 2684

SAS OnlineDoc: Version 8

Page 20: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2678 � Chapter 50. The PLAN Procedure

Randomizing Designs

In many situations, proper randomization is crucial for the validity of any conclusionsto be drawn from an experiment. Randomization is used both to neutralize the effectof any unknown systematic biases that may be involved in the design as well as toprovide a basis for the assumptions underlying the analysis.

You can use PROC PLAN to randomize an already-existing design: one produced bya previous call to PROC PLAN, perhaps, or a more specialized design taken from astandard reference such as Cochran and Cox (1957). The method is to specify theappropriate block structure in the FACTORS statement and then to specify the dataset where the design is stored with the DATA= option in the OUTPUT statement. Foran illustration of this method, see the “Randomly Assigning Subjects to Treatments”section on page 2663).

Two sorts of randomization are provided for, corresponding to the RANDOM fac-tor selection and association types in the FACTORS and OUTPUT statements, re-spectively. Designs in which factors are completely nested (for example, block de-signs) should be randomized by specifying that the selection type of each factor isRANDOM in the FACTORS statement, which is the default (see Example 50.3 onpage 2681). On the other hand, if the factors are crossed (for example, row-and-column designs), they should be randomized by one random reassignment of theirvalues for the whole design. To do this, specify that the association type of eachfactor is RANDOM in the OUTPUT statement (see Example 50.4 on page 2683).

Displayed Output

The PLAN procedure displays

� them value for each factor, which is the number of values to be selected

� then value for each factor, which is the number of values to be selected from

� the selection type for each factor, as specified in the FACTORS statement

� the initial block and increment number for cyclic factors

� the factor value selections making up each plan

In addition, notes are written to the log giving the starting and ending values of therandom number seed for each call to PROC PLAN.

ODS Table Names

PROC PLAN assigns a name to each table it creates. You can use these names toreference the table when using the Output Delivery System (ODS) to select tablesand create output data sets. These names are listed in the following table. For moreinformation on ODS, see Chapter 15, “Using the Output Delivery System.”

SAS OnlineDoc: Version 8

Page 21: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

Example 50.2. A Hierarchical Design � 2679

Table 50.3. ODS Tables Produced by PROC PLAN

ODS Table Name Description StatementFInfo General factor information FACTOR & no TREATMENTPFInfo Plot factor information FACTOR & TREATMENTPlan Computed plan defaultTFInfo Treatment factor information FACTOR & TREATMENT

Examples

Example 50.1. A Split-Plot Design

This plan is appropriate for a split-plot design with main plots forming a randomizedcomplete block design. In this example, there are three blocks, four main plots perblock, and two subplots per main plot. First, three random permutations (one for eachof theblocks) of the integers 1, 2, 3, and 4 are produced. The four integers correspondto the four levels of the main plot factora; the permutation determines how the levelsof a are assigned to the main plots within a block. For each of these twelve numbers(four numbers per block for three blocks), a random permutation of the integers 1 and2 is produced. Each two-integer permutation determines the assignment of the twolevels of the subplot factorb within a main plot. The following statements produceOutput 50.1.1:

title ’Split Plot Design’;proc plan seed=37277;

factors block=3 ordered a=4 b=2;run;

Output 50.1.1. A Split-Plot Design

Split Plot Design

The PLAN Procedure

Factor Select Levels Order

block 3 3 Ordereda 4 4 Randomb 2 2 Random

block a -b-

1 4 2 13 2 11 2 12 2 1

2 4 1 23 1 21 2 12 1 2

3 4 2 12 2 13 2 11 2 1

SAS OnlineDoc: Version 8

Page 22: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2680 � Chapter 50. The PLAN Procedure

Example 50.2. A Hierarchical Design

In this example, three plants are nested within four pots, which are nested within threehouses. The FACTORS statement requests a random permutation of the numbers 1,2, and 3 to chooseHouses randomly. The second step requests a random permuta-tion of the numbers 1, 2, 3, and 4 for each of those first three numbers to randomlyassignPots to Houses. Finally, the FACTORS statement requests a random permu-tation of 1, 2, and 3 for each of the twelve integers in the second set of permutations.This last step randomly assignsPlants to Pots. The following statements produceOutput 50.2.1:

title ’Hierarchical Design’;proc plan seed=17431;

factors Houses=3 Pots=4 Plants=3 / noprint;output out=nested;

run;

proc print data=nested;run;

Output 50.2.1. A Hierarchical Design

Hierarchical Design

Obs Houses Pots Plants

1 1 3 22 1 3 33 1 3 14 1 1 35 1 1 16 1 1 27 1 2 28 1 2 39 1 2 1

10 1 4 311 1 4 212 1 4 113 2 4 114 2 4 315 2 4 216 2 2 217 2 2 118 2 2 319 2 3 220 2 3 321 2 3 122 2 1 223 2 1 324 2 1 125 3 4 126 3 4 327 3 4 228 3 1 329 3 1 230 3 1 131 3 2 132 3 2 233 3 2 334 3 3 335 3 3 236 3 3 1

SAS OnlineDoc: Version 8

Page 23: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

Example 50.3. An Incomplete Block Design � 2681

Example 50.3. An Incomplete Block Design

Jarrett and Hall (1978) give an example of a generalized cyclic design with goodefficiency characteristics. The design consists of two replicates of 52 treatments in13 blocks of size 8. The following statements use the PLAN procedure to generatethis design in an appropriately randomized form and store it in a SAS data set. Then,the TABULATE procedure is used to display the randomized plan. The followingstatements produce Output 50.3.1 and Output 50.3.2:

title ’Generalized Cyclic Block Design’;proc plan seed=33373;

treatments trtmts=8 of 52 cyclic (1 2 3 4 32 43 46 49) 4;factors blocks=13 plots=8;output out=c;

quit;

proc tabulate;class blocks plots;var trtmts;table blocks, plots*(trtmts*f=8.) / rts=8;

run;

Output 50.3.1. A Generalized Cyclic Block Design

Generalized Cyclic Block Design

The PLAN Procedure

Plot Factors

Factor Select Levels Order

blocks 13 13 Randomplots 8 8 Random

Treatment Factors

Factor Select Levels Order Initial Block / Increment

trtmts 8 52 Cyclic (1 2 3 4 32 43 46 49) / 4

blocks -----plots----- ---------trtmts--------

10 7 4 8 1 2 3 5 6 1 2 3 4 32 43 46 498 1 2 4 3 8 6 5 7 5 6 7 8 36 47 50 19 2 5 4 7 3 1 8 6 9 10 11 12 40 51 2 56 4 2 6 8 3 7 1 5 13 14 15 16 44 3 6 97 4 7 6 3 1 2 8 5 17 18 19 20 48 7 10 134 4 8 1 5 3 6 7 2 21 22 23 24 52 11 14 172 6 2 3 8 7 5 1 4 25 26 27 28 4 15 18 213 6 2 3 1 7 4 5 8 29 30 31 32 8 19 22 251 1 2 7 8 5 6 3 4 33 34 35 36 12 23 26 295 5 7 6 8 4 3 1 2 37 38 39 40 16 27 30 33

12 5 8 1 4 7 3 6 2 41 42 43 44 20 31 34 3713 3 5 1 8 4 2 6 7 45 46 47 48 24 35 38 4111 4 1 5 2 3 8 6 7 49 50 51 52 28 39 42 45

SAS OnlineDoc: Version 8

Page 24: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2682 � Chapter 50. The PLAN Procedure

Output 50.3.2. A Generalized Cyclic Block Design

Generalized Cyclic Block Design

--------------------------------------------------------------------------------| | plots || |-----------------------------------------------------------------------|| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 || |--------+--------+--------+--------+--------+--------+--------+--------|| | trtmts | trtmts | trtmts | trtmts | trtmts | trtmts | trtmts | trtmts || |--------+--------+--------+--------+--------+--------+--------+--------|| | Sum | Sum | Sum | Sum | Sum | Sum | Sum | Sum ||------+--------+--------+--------+--------+--------+--------+--------+--------||blocks| | | | | | | | ||------| | | | | | | | ||1 | 33| 34| 26| 29| 12| 23| 35| 36||------+--------+--------+--------+--------+--------+--------+--------+--------||2 | 18| 26| 27| 21| 15| 25| 4| 28||------+--------+--------+--------+--------+--------+--------+--------+--------||3 | 32| 30| 31| 19| 22| 29| 8| 25||------+--------+--------+--------+--------+--------+--------+--------+--------||4 | 23| 17| 52| 21| 24| 11| 14| 22||------+--------+--------+--------+--------+--------+--------+--------+--------||5 | 30| 33| 27| 16| 37| 39| 38| 40||------+--------+--------+--------+--------+--------+--------+--------+--------||6 | 6| 14| 44| 13| 9| 15| 3| 16||------+--------+--------+--------+--------+--------+--------+--------+--------||7 | 48| 7| 20| 17| 13| 19| 18| 10||------+--------+--------+--------+--------+--------+--------+--------+--------||8 | 5| 6| 8| 7| 50| 47| 1| 36||------+--------+--------+--------+--------+--------+--------+--------+--------||9 | 51| 9| 40| 11| 10| 5| 12| 2||------+--------+--------+--------+--------+--------+--------+--------+--------||10 | 4| 32| 43| 2| 46| 49| 1| 3||------+--------+--------+--------+--------+--------+--------+--------+--------||11 | 50| 52| 28| 49| 51| 42| 45| 39||------+--------+--------+--------+--------+--------+--------+--------+--------||12 | 43| 37| 31| 44| 41| 34| 20| 42||------+--------+--------+--------+--------+--------+--------+--------+--------||13 | 47| 35| 45| 24| 46| 38| 41| 48|--------------------------------------------------------------------------------

SAS OnlineDoc: Version 8

Page 25: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

Example 50.4. A Latin Square Design � 2683

Example 50.4. A Latin Square Design

All of the preceding examples involve designs with completely nested block struc-tures, for which PROC PLAN was especially designed. However, by appropriatecoordination of its facilities, a much wider class of designs can be accommodated.A Latin square design is based on experimental units that have a row-and-columnblock structure. The following example uses the CYCLIC option for a treatment fac-tor tmts to generate a simple4� 4 Latin square. Randomizing a Latin square designinvolves randomly permuting the row, column, and treatment values independently.In order to do this, use the RANDOM option in the OUTPUT statement of PROCPLAN. The example also usesfactor-value-settingsin the OUTPUT statement. Thefollowing statements produce Output 50.4.1:

title ’Latin Square Design’;proc plan seed=37430;

factors rows=4 ordered cols=4 ordered / noprint;treatments tmts=4 cyclic;output out=g

rows cvals=(’Day 1’ ’Day 2’ ’Day 3’ ’Day 4’) randomcols cvals=(’Lab 1’ ’Lab 2’ ’Lab 3’ ’Lab 4’) randomtmts nvals=( 0 100 250 450 ) random;

quit;

proc tabulate;class rows cols;var tmts;table rows, cols*(tmts*f=6.) / rts=8;

run;

Output 50.4.1. A Randomized Latin Square Design

Latin Square Design

------------------------------------| | cols || |---------------------------|| |Lab 1 |Lab 2 |Lab 3 |Lab 4 || |------+------+------+------|| | tmts | tmts | tmts | tmts || |------+------+------+------|| | Sum | Sum | Sum | Sum ||------+------+------+------+------||rows | | | | ||------| | | | ||Day 1 | 0| 250| 100| 450||------+------+------+------+------||Day 2 | 250| 450| 0| 100||------+------+------+------+------||Day 3 | 100| 0| 450| 250||------+------+------+------+------||Day 4 | 450| 100| 250| 0|------------------------------------

SAS OnlineDoc: Version 8

Page 26: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2684 � Chapter 50. The PLAN Procedure

Example 50.5. A Generalized Cyclic Incomplete Block Design

The following statements depict how to create an appropriately randomized gener-alized cyclic incomplete block design forv treatments (given by the value oft) in bblocks (given by the value ofb) of sizek (with values ofp indexing the cells withina block) with initial block(e1 e2 � � � ek) and increment numberi.

factors b= b p=k ;

treatments t= k of v cyclic ( e1 e2 � � � ek ) i ;

For example, the specification

proc plan seed=37430;factors b=10 p=4;treatments t=4 of 30 cyclic (1 3 4 26) 2;

run;

generates the generalized cyclic incomplete block design given in Example 1 of Jar-rett and Hall (1978), which is given by the rows and columns of the plan associatedwith the treatment factort in Output 50.5.1.

Output 50.5.1. A Generalized Cyclic Incomplete Block Design

The PLAN Procedure

Plot Factors

Factor Select Levels Order

b 10 10 Randomp 4 4 Random

Treatment Factors

Initial BlockFactor Select Levels Order / Increment

t 4 30 Cyclic (1 3 4 26) / 2

b ---p--- -----t-----

2 2 3 1 4 1 3 4 261 3 2 4 1 3 5 6 283 2 3 4 1 5 7 8 30

10 4 2 3 1 7 9 10 29 4 1 2 3 9 11 12 44 1 3 2 4 11 13 14 65 1 2 4 3 13 15 16 88 3 2 4 1 15 17 18 107 2 4 1 3 17 19 20 126 2 1 4 3 19 21 22 14

SAS OnlineDoc: Version 8

Page 27: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

Example 50.6. Permutations and Combinations � 2685

Example 50.6. Permutations and Combinations

Occasionally, you may need to generate all possible permutations ofn things, or allpossible combinations ofn things takenm at a time.

For example, suppose you are planning an experiment in cognitive psychology whereyou want to present four successive stimuli to each subject. You want to observe eachpermutation of the four stimuli. The following statements use PROC PLAN to createa data set containing all possible permutations of 4 numbers in random order.

title ’All Permutations of 1,2,3,4’;proc plan seed=60359;

factors Subject = 24Order = 4 ordered;

treatments Stimulus = 4 perm;output out=Psych;

proc sort data=Psych out=Psych;by Subject Order;

proc tabulate formchar=’ ’ noseps;class Subject Order;var Stimulus;table Subject, Order*(Stimulus*f=8.)*sum=’ ’ / rts=9;

run;

The variableSubject is set at 24 levels because there are4! = 24 total permutationsto be listed. IfSubject> 24, the list repeats. Output 50.6.1 displays the PROC PLANoutput. Note that the variableSubject is listed in random order.

Output 50.6.1. List of Permutations

All Permutations of 1,2,3,4

The PLAN Procedure

Plot Factors

Factor Select Levels Order

Subject 24 24 RandomOrder 4 4 Ordered

Treatment Factors

Factor Select Levels Order

Stimulus 4 4 Perm

SAS OnlineDoc: Version 8

Page 28: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2686 � Chapter 50. The PLAN Procedure

All Permutations of 1,2,3,4

The PLAN Procedure

Subject -Order- -Stimulus-

4 1 2 3 4 1 2 3 415 1 2 3 4 1 2 4 324 1 2 3 4 1 3 2 4

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

17 1 2 3 4 1 4 3 219 1 2 3 4 2 1 3 414 1 2 3 4 2 1 4 3

6 1 2 3 4 2 3 1 423 1 2 3 4 2 3 4 1

8 1 2 3 4 2 4 1 32 1 2 3 4 2 4 3 1

13 1 2 3 4 3 1 2 416 1 2 3 4 3 1 4 212 1 2 3 4 3 2 1 418 1 2 3 4 3 2 4 121 1 2 3 4 3 4 1 2

9 1 2 3 4 3 4 2 122 1 2 3 4 4 1 2 310 1 2 3 4 4 1 3 2

7 1 2 3 4 4 2 1 311 1 2 3 4 4 2 3 1

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

The output data setPsych contains 96 observations of the 3 variables (Subject,Order, andStimulus). Sorting the output data set bySubject and byOrder withinSubject results in all possible permutations ofStimulus in random order. PROCTABULATE displays these permutations in Output 50.6.2.

SAS OnlineDoc: Version 8

Page 29: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

Example 50.6. Permutations and Combinations � 2687

Output 50.6.2. Randomized Permutations

All Permutations of 1,2,3,4

Order

1 2 3 4

Stimulus Stimulus Stimulus Stimulus

Subject1 1 3 4 22 2 4 3 13 4 3 1 24 1 2 3 45 1 4 2 36 2 3 1 47 4 2 1 38 2 4 1 39 3 4 2 110 4 1 3 211 4 2 3 112 3 2 1 413 3 1 2 414 2 1 4 315 1 2 4 316 3 1 4 217 1 4 3 218 3 2 4 119 2 1 3 420 4 3 2 121 3 4 1 222 4 1 2 323 2 3 4 124 1 3 2 4

As another example, suppose you have six alternative treatments, any four of whichcan occur together in a block (in no particular order). The following statements usePROC PLAN to create a data set containing all possible combinations of six numberstaken four at a time. In this case, you use ODS to create the data set.

title ’All Combinations of (6 Choose 4) Integers’;ods output Plan=Combinations;proc plan;

factors Block=15 orderedTreat= 4 of 6 comb;

run;proc print data=Combinations noobs;run;

The variableBlock has 15 levels since there are a total of6!=(4!2!) = 15 combina-tions of four integers chosen from six integers. The data set formed by ODS from thedisplayed plan has one row for each block, with the four values ofTreat correspond-ing to four different variables, as shown in Output 50.6.3.

SAS OnlineDoc: Version 8

Page 30: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

2688 � Chapter 50. The PLAN Procedure

Output 50.6.3. List of Combinations

All Combinations of (6 Choose 4) Integers

The PLAN Procedure

Factor Select Levels Order

Block 15 15 OrderedTreat 4 6 Comb

Block -Treat-

1 1 2 3 42 1 2 3 53 1 2 3 64 1 2 4 55 1 2 4 66 1 2 5 67 1 3 4 58 1 3 4 69 1 3 5 6

10 1 4 5 611 2 3 4 512 2 3 4 613 2 3 5 614 2 4 5 615 3 4 5 6

Output 50.6.4. Combinations Data Set Created by ODS

All Combinations of (6 Choose 4) Integers

Block Treat1 Treat2 Treat3 Treat4

1 1 2 3 42 1 2 3 53 1 2 3 64 1 2 4 55 1 2 4 66 1 2 5 67 1 3 4 58 1 3 4 69 1 3 5 6

10 1 4 5 611 2 3 4 512 2 3 4 613 2 3 5 614 2 4 5 615 3 4 5 6

SAS OnlineDoc: Version 8

Page 31: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

References � 2689

References

Cochran, W.G. and Cox, G.M. (1957),Experimental Designs, Second Edition, NewYork: John Wiley & Sons, Inc.

Fishman, G.S. and Moore, L.R. (1982), “A Statistical Evaluation of MultiplicativeCongruential Generators with Modulus(231 � 1),” Journal of the American Sta-tistical Association, 77, 129–136.

Jarrett, R.G. and Hall, W.B. (1978), “Generalized Cyclic Incomplete Block Designs,”Biometrika, 65, 397–401.

SAS OnlineDoc: Version 8

Page 32: The PLAN Procedure - Worcester Polytechnic · PDF fileThe PLAN procedure can construct the following types ... The randomized selection method can be used to generate ... the increment

The correct bibliographic citation for this manual is as follows: SAS Institute Inc.,SAS/STAT ® User’s Guide, Version 8, Cary, NC: SAS Institute Inc., 1999.

SAS/STAT® User’s Guide, Version 8Copyright © 1999 by SAS Institute Inc., Cary, NC, USA.ISBN 1–58025–494–2All rights reserved. Produced in the United States of America. No part of this publicationmay be reproduced, stored in a retrieval system, or transmitted, in any form or by anymeans, electronic, mechanical, photocopying, or otherwise, without the prior writtenpermission of the publisher, SAS Institute Inc.U.S. Government Restricted Rights Notice. Use, duplication, or disclosure of thesoftware and related documentation by the U.S. government is subject to the Agreementwith SAS Institute and the restrictions set forth in FAR 52.227–19 Commercial ComputerSoftware-Restricted Rights (June 1987).SAS Institute Inc., SAS Campus Drive, Cary, North Carolina 27513.1st printing, October 1999SAS® and all other SAS Institute Inc. product or service names are registered trademarksor trademarks of SAS Institute Inc. in the USA and other countries.® indicates USAregistration.Other brand and product names are registered trademarks or trademarks of theirrespective companies.The Institute is a private company devoted to the support and further development of itssoftware and related services.