Shared Concepts and Topics |
The majority of the modeling procedures in SAS/STAT can take advantage of the fact that the statistical model can easily be translated into programming syntax (statements and options). Several procedures, however, require additional flexibility in specifying models—for example, when the model contains general nonlinear functions, when it is necessary to specify complicated restrictions, or when user-supplied expressions need to be evaluated. These procedures, listed at the beginning of the section, support—in addition to the usual procedure statements and options—programming statements that can be used in the SAS DATA step.
The following are valid statements:
ABORT;
CALL name < ( expression <, expression ...> ) >;
DELETE;
DO < variable = expression
<TO expression> <BY expression>
<, expression < TO expression> < BY expression > ...>
>
< WHILE expression > < UNTIL expression >;
END;
GOTO statement-label;
IF expression;
IF expression THEN program-statement;
ELSE program-statement;
variable = expression;
variable + expression;
LINK statement-label;
PUT < variable> <=> <...>;
RETURN;
SELECT <( expression )>;
STOP;
SUBSTR( variable, index, length ) = expression;
WHEN (expression) program-statement;
OTHERWISE program-statement;
For the most part, these programming statements work the same as they do in the SAS DATA step, as documented in SAS Language Reference: Concepts. However, there are several differences:
The ABORT statement does not allow any arguments.
The DO statement does not allow a character index variable. Thus
do i = 1,2,3;
is supported, whereas the following statement is not supported:
do i = 'A','B','C';
Not all procedures support LAG functionality. For example, the GLIMMIX procedure does not support lags.
The PUT statement, used mostly for program debugging, supports only some of the features of the DATA step PUT statement, and it has some features not available with the DATA step PUT statement:
The PUT statement does not support line pointers, factored lists, iteration factors, overprinting, _INFILE_, the colon (:) format modifier, or "$".
The PUT statement does support expressions, but the expression must be enclosed in parentheses. For example, the following statement displays the square root of x:
put (sqrt(x));
The PUT statement supports the item _PDV_ to display a formatted listing of all variables in the program. For example:
put _pdv_;
The WHEN and OTHERWISE statements enable you to specify more than one target statement. That is, DO/END groups are not necessary for multiple-statement WHENs. For example, the following syntax is valid:
select; when (exp1) stmt1; stmt2; when (exp2) stmt3; stmt4; end;
Please consult the individual chapters for other, procedure-specific differences between programming statements and the SAS DATA step and for procedure-specific details, limitations, and rules.
The LINK statement is used in a program to jump immediately to the label statement_label and to continue program execution at that point. It is not used to specify a link function in a generalized linear model.
When coding your programming statements, you should avoid defining variables that begin with an underscore (_), because they might conflict with internal variables created by procedures that support programming statements.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.