The MCMC Procedure

Programming Statements

This section lists the programming statements available in PROC MCMC to compute the priors and log-likelihood functions. This section also documents the differences between programming statements in PROC MCMC and programming statements in the DATA step. The syntax of programming statements used in PROC MCMC is identical to that used in the NLMIXED procedure (see Chapter 70: The NLMIXED Procedure) and the MODEL procedure (see Chapter 19: The MODEL Procedure in SAS/ETS 13.2 User's Guide,). Most of the programming statements that can be used in the DATA step can also be used in PROC MCMC. See SAS Language Reference: Dictionary for a description of SAS programming statements.

There are also a number of unique functions in PROC MCMC that calculate the log density of various distributions in the procedure. You can find them at the section Using Density Functions in the Programming Statements.

For the list of matrix-based functions that is supported in PROC MCMC, see the section Matrix Functions in PROC MCMC.

The following are valid statements:

  • ABORT;

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

  • 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, the SAS programming statements work the same as they do in the 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; however, the following statement is not supported:

       do i = 'A','B','C';
    
  • The PUT statement, used mostly for program debugging in PROC MCMC (see the section Handling Error Messages), 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 PROC MCMC PUT statement does not support line pointers, factored lists, iteration factors, overprinting, _INFILE_, _OBS_, the colon (:) format modifier, or "$".

    • The PROC MCMC 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 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;
    

You should avoid defining variables that begin with an underscore (_). They might conflict with internal variables created by PROC MCMC. The MODEL statement must come after any SAS programming statements that define or modify terms used in the construction of the log likelihood.