Chapter Contents |
Previous |
Next |

The MODEL Procedure |

do i = 'A', 'B', 'C'; /* invalid PROC MODEL code */

if 'this' then statement;

Comparisons of character values are supported in IF statements, so the following IF statement is acceptable:

if 'this' < 'that' then statement};

PROC MODEL allows for embedded conditionals in expressions. For example the following two statements are equivalent:

flag = if time = 1 or time = 2 then conc+30/5 + dose*time else if time > 5 then (0=1) else (patient * flag);

if time = 1 or time = 2 then flag= conc+30/5 + dose*time; else if time > 5 then flag=(0=1); else flag=patient*flag;Note that the ELSE operator only involves the first object or token after it so that the following assignments are not equivalent:

total = if sum > 0 then sum else sum + reserve; total = if sum > 0 then sum else (sum + reserve);The first assignment makes TOTAL always equal to SUM plus RESERVE.

The PROC MODEL PUT statement does not support line pointers, factored lists, iteration factors, overprinting, the _INFILE_ option, or the colon (:) format modifier.

The PROC MODEL PUT statement does support expressions but an expression must be enclosed in parentheses. For example, the following statement prints the square root of x:

put (sqrt(x));

Subscripted array names must be enclosed in parentheses.
For example, the following statement
prints the *i*th element of the array A:

put (a i);

However, the following statement is an error:

put a i;

The PROC MODEL PUT statement supports the print item _PDV_ to print a formatted listing of all the variables in the program. For example, the following statement prints a much more readable listing of the variables than does the _ALL_ print item:

put _pdv_;

To print all the elements of the array A, use the following statement:

put a;

To print all the elements of A with each value labeled by the name of the element variable, use the statement

put a=;

select; when(exp1) stmt1; stmt2; when(exp2) stmt3; stmt4; end;

**ARRAY***arrayname [{dimensions}] [$ [length]] [ variables and constants];*

The ARRAY statement is used to associate a name with a list of variables and constants. The array name can then be used with subscripts in the model program to refer to the items in the list.

In PROC MODEL, the ARRAY statement does not support all the features of the DATA step ARRAY statement. Implicit indexing cannot be used; all array references must have explicit subscript expressions. Only exact array dimensions are allowed; lower-bound specifications are not supported. A maximum of six dimensions is allowed.

On the other hand, the ARRAY statement supported by PROC MODEL does allow both variables and constants to be used as array elements. You cannot make assignments to constant array elements. Both dimension specification and the list of elements are optional, but at least one must be supplied. When the list of elements is not given or fewer elements than the size of the array are listed, array variables are created by suffixing element numbers to the array name to complete the element list.

The following are valid PROC MODEL array statements:

array x[120]; /* array X of length 120 */ array q[2,2]; /* Two dimensional array Q */ array b[4] va vb vc vd; /* B[2] = VB, B[4] = VD */ array x x1-x30; /* array X of length 30, X[7] = X7 */ array a[5] (1 2 3 4 5); /* array A initialized to 1,2,3,4,5 */

**RETAIN***variables initial-values ;*

The RETAIN statement does not work for model variables, parameters, or control variables because the values of these variables are under the control of PROC MODEL and not programming statements. Use the PARMS and CONTROL statements to initialize parameters and control variables. Use the VAR, ENDOGENOUS, or EXOGENOUS statement to initialize model variables.

Chapter Contents |
Previous |
Next |
Top |

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.