Previous Page | Next Page

Shared Concepts and Topics

Programming Statements

This section applies to the following procedures:
CALIS, GLIMMIX, MCMC, NLIN, NLMIXED, and TCALIS.

The majority of the SAS/STAT modeling procedures can take advantage of the fact that the statistical model can easily be translated into programming syntax (statements and options). However, several procedures 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. Procedures that are 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 that are 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;
    
  • 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.

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.

When coding your programming statements, avoid defining variables that begin with an underscore (_), because they might conflict with internal variables that are created by procedures that support programming statements.


Previous Page | Next Page | Top of Page