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 one FACTORS statement before the first RUN statement. The TREATMENTS statement, OUTPUT statement, and additional FACTORS statements can appear either before the first RUN statement or after it. The rest of this section gives detailed syntax information 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 3346.

PROC PLAN Statement

  • PROC PLAN < options > ;

The PROC PLAN statement starts the PLAN procedure and, optionally , specifies a random 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 day from the computer s clock and randomly selects levels of factors. These defaults can be modified with the SEED= and ORDERED options, respectively. Unlike many SAS/STAT procedures, the PLAN procedure does not have a DATA= option in the PROC statement; in this procedure, both the input and output data sets are specified in the OUTPUT statement.

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

SEED= number

  • specifies an integer used to start the pseudo-random number generator for selecting factor levels randomly. If you don t specify a seed, or specify a value less than or equal to zero, the seed is by default generated from reading the time of day from the computer s clock.

ORDERED

FACTORS Statement

  • FACTORS factor-selections < / NOPRINT > ;

The FACTORS statement specifies the factors of the plan and generates the plan. Taken together, the factor-selections specify the plan to be generated; more than one factor-selection request can be used in a FACTORS statement. The form of a factor-selection is

  • 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. If n is specified, the value of m must be less than or equal to n .

n

is a positive integer that gives the number of values to be selected from.

selection-type

specifies one of five methods for selecting m values. Possible values are COMB, CYCLIC, ORDERED, PERM or RANDOM. The CYCLIC selection-type has additional optional specifications that enable you to specify an initial block of numbers to be cyclically permuted and an increment used to permute the numbers . By default, the selection-type is RANDOM, unless you use the ORDERED option in the PROC PLAN statement. In this case, the default selection-type is 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:

NOPRINT

  • suppresses the display of the plan. This is particularly useful when you require only an output data set. Note that this option temporarily disables the Output Delivery System (ODS); see Chapter 14, Using the Output Delivery System, for more information.

Selection-Types

PROC PLAN interprets selection-type as follows :

RANDOM

selects the m levels of the factor randomly without replacement from the integers 1 , 2 , ..., n . Or, if n is not specified, RANDOM selects levels by randomly ordering the integers 1 , 2 , ..., m .

ORDERED

selects the levels of the factor as the integers 1 , 2 , ..., m , in that order.

PERM

selects the m levels of the factor as a permutation of the integers 1 , ... m according to an algorithm that cycles through all m ! permutations. The permutations are produced in a sorted standard order; see Example 55.6 on page 3358.

COMB

selects the m levels of the factor as a combination of the integers 1 , ..., n taken m at a time, according to an algorithm that cycles through all n ! / ( m !( n ˆ’ m )!) combinations. The combinations are produced in a sorted standard order; see Example 55.6 on page 3358.

CYCLIC < ( initial-block ) >< increment >

selects the levels of the factor by cyclically permuting the integers 1 , 2 , ..., n . Wrapping occurs at m if n is not specified, and at n if n is specified. Additional optional specifications are as follows:

With the selection-type CYCLIC, you can optionally specify an initial-block and an increment . The initial-block must be specified within parentheses, and it specifies the block of numbers to permute. The first permutation is the block you specify, the second is the block permuted by 1 (or by the increment you specify), and so on. By default, the initial-block is the integers 1 , 2 , ..., m . If you specify an initial-block , it must have m values. Values specified in the initial-block do not have to be given in increasing order.

The increment specifies the increment by which to permute the block of numbers. By default, the increment is 1.

Syntax Examples

This section gives some simple syntax examples. For more complex examples and details on how to generate various designs, see the Specifying Factor Structures section on page 3348. The examples in this section assume that you use the default random selection method and do not use the ORDERED option in the PROC PLAN statement.

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 from 1 to 8, selected without replacement.

  factors A=5 of 8;  

Adding the ORDERED selection-type to the two previous specifications generates an ordered list of the integers 1 to 5. The following specification cyclically permutes the integers 1, 2, 3, and 4.

  factors A=4 cyclic;  

Since this simple request generates only one permutation of the numbers, the procedure generates an ordered list of the integers 1 to 4. The following specification cyclically 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 an ordered list of the integers 5 to 8. The following specification produces an ordered list 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 for B are 5, 6, 7, 8 for level 1 of A ; and 7, 8, 1, 2 for level 2 of A .

Handling More than One Factor-Selection

For cases with more than one factor-selection in the same FACTORS statement, PROC PLAN constructs the design as follows:

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

  2. For every integer generated for the first factor-selection , levels are generated for the second factor-selection . These levels are generated according to the specifications following the second equal sign.

  3. This process is repeated until levels for all factor-selections have been generated.

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

  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 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.

As another example, six random permutations of the numbers 1, 2, 3 can be generated by 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 PROC PLAN interactively, the OUTPUT statement for a given plan must be immediately preceded by the FACTORS statement (and the TREATMENTS statement, if appropriate) for the plan. See the Output Data Sets section on page 3346 for more information on how output data sets are constructed . You can specify the following options in the OUTPUT statement:

OUT= SAS-data-set

DATA = SAS-data-set

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

  • When you specify only the OUT= option in the OUTPUT statement, PROC PLAN saves the last plan generated to the specified data set. The output data set contains one 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 factor for 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 has the same form as the input data set but has modified values for the variables that correspond to factors (see the Output Data Sets section on page 3346 for details). Values for variables not corresponding to factors are transferred without change.

factor-value-settings

specify the values input or output for the factors in the design. The form for factor-value-settings is different when only an OUT= data set is specified and when both OUT= and DATA= data sets are specified. Both forms are discussed in the following section.

Factor-Value-Settings with Only an OUT= Data Set

When you specify only an OUT= data set, the form for each factor-value-setting specification 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 OUTPUT statement.

NVALS=

lists n numeric values for the factor. By default, the procedure uses NVALS=(1 2 3 ...n ).

CVALS=

lists n character strings for the factor. Each string can have up to 40 characters , and each string must be enclosed in quotes. Warning: When you use the CVALS= option, the variable created in the output data set has a length equal to the length of the longest string given as a value; shorter strings are padded with trailing blanks. For example, the values output for the first level of a two-level factor with 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 followed by seven blanks. In order to match two such values (for example, when merging two plans), you must use the TRIM function in the DATA step (refer to SAS Language Reference: Dictionary ).

ORDERED RANDOM

specifies how values (those given with the NVALS= or CVALS= option, or the default values) are associated with the levels of a factor (the integers 1 , 2 , ..., n ). The default association type is ORDERED, for which the first value specified is output for a factor level setting of 1, the second value specified is output for a level of 2, and so on. You can also specify an association type of RANDOM, for which the levels are associated with the values in a random order. Specifying RANDOM is useful for randomizing crossed experiments (see the Randomizing Designs section on page 3351).

The following statements give an example of using the OUTPUT statement with only an 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 and b . The values of the variable a are 10 when factor a equals 1, 20 when factor a equals 2, and so on. Values of the variable b are ˜HSX when factor b equals 1, ˜SB2 when factor b equals 2, and ˜DNY when factor b equals 3.

Factor-Value-Settings with OUT= and DATA= Data Sets

If you specify an input data set with DATA=, then PROC PLAN assumes that each factor in the last plan generated corresponds to a variable in the input set. If the variable name is different from the name of the factor to which it corresponds, the two 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 by NVALS= or CVALS= specify the input values as well as the output values for the corresponding variable.

Since the procedure assumes that the collection of input factor values constitutes a plan position description (see the Output Data Sets section on page 3346), the values must correspond to integers less than or equal to m , the number of values selected for the associated factor. If any input values do not correspond, then the collection does not define a plan position, and the corresponding observation is output without changing the values of any of the factor variables.

The following statements demonstrate the use of factor-value settings. The input SAS data set a contains variables Block and Plot , which are renamed Day and Hour , 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 Randomly Assigning Subjects to Treatments section on page 3337.

TREATMENTS Statement

  • TREATMENTS factor-selections ;

The TREATMENTS statement specifies the treatments of the plan to generate, but it does not generate a plan. If you supply several FACTORS and TREATMENTS statements before the first RUN statement, the procedure uses only the last TREATMENTS specification and applies it to the plans generated by each of the FACTORS statements. The TREATMENTS statement has the same form as the FACTORS statement. The individual factor-selections also have the same form as in the FACTORS statement:

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

The procedure generates each treatment simultaneously with the lowest (that is, the most nested) factor in the last FACTORS statement. The m value for each treatment must be at least as large as the m for the most-nested factor.

The following statements give an example of using both a FACTORS and a TREATMENTS statement. First the FACTORS statement sets up the rows and columns of a 3 — 3 square (factors r and c ). Then, the TREATMENTS statement augments the square with two cyclic treatments. The resulting design is a 3 — 3 Graeco-Latin square, 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 values of r and c are ordered (1, 2, 3) as requested .

  r      --c--      --a--      --b--   1      1 2 3      1 2 3      1 2 3   2      1 2 3      2 3 1      3 1 2   3      1 2 3      3 1 2      2 3 1  



SAS.STAT 9.1 Users Guide (Vol. 5)
SAS.STAT 9.1 Users Guide (Vol. 5)
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 98

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net