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 ith 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 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 */
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.