The NLMIXED Procedure

Programming Statements

This section lists the programming statements that are used to code the log-likelihood function in PROC NLMIXED. It also documents the differences between programming statements in PROC NLMIXED and programming statements in the SAS DATA step. The syntax of programming statements used in PROC NLMIXED is identical to that used in the CALIS and GENMOD procedures (see Chapter 29 and Chapter 43, respectively), and the MODEL procedure (see the SAS/ETS User's Guide). Most of the programming statements that can be used in the SAS DATA step can also be used in the NLMIXED procedure. See SAS Language Reference: Dictionary for a description of SAS programming statements. The following are valid statements:

  • ABORT;

  • ARRAY arrayname <[ dimensions ]> <$> <variables-and-constants>;

  • CALL name <(expression <, expression …>)>;


  • 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> <=> …;


  • SELECT <(expression)>;

  • STOP;

  • SUBSTR(variable, index, length)= expression;

  • WHEN (expression)program-statement;

  • OTHERWISE program-statement;

For the most part, the SAS programming statements work the same as they do in the SAS DATA step, as documented in SAS Language Reference: Concepts; however, there are the following 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, but the following statement is not supported:

    do i = 'A','B','C';

  • The LAG function does work appropriately with PROC NLMIXED, but you can use the ZLAG function instead.

  • The PUT statement, used mostly for program debugging in PROC NLMIXED, supports only some of the features of the DATA step PUT statement, and it has some new features that the DATA step PUT statement does not.

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

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

      $\mt {put \quad (sqrt(x));}$

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

      $\mt {put \quad \_ 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:

       when (exp1) stmt1;
       when (exp2) stmt3;

When coding your programming statements, you should avoid defining variables that begin with an underscore (_), because they might conflict with internal variables created by PROC NLMIXED. The MODEL statement must come after any SAS programming statements that define or modify terms used in the construction of the log-likelihood.