GAMSELECT Procedure

Programming Statements

A number of programming statements are available in the GAMSELECT procedure that enable you to create computed variables on the fly. For example, you can compute model effects, weights, frequency, and other variables. This section lists these programming statements and also documents the differences between them and programming statements available in the SAS DATA step. The syntax of programming statements that is used in PROC GAMSELECT is identical to that used in the NLMIXED procedure (see Chapter 89, The NLMIXED Procedure (SAS/STAT User's Guide) and the MODEL procedure (see the SAS/ETS User's Guide). Most of the programming statements available in the DATA step are also available in PROC GAMSELECT. See SAS DATA Step Statements: Reference for a description of SAS programming statements.

You can specify the following programming statements:

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

  • RETURN;

  • SELECT <(expression)>;

  • STOP;

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

  • WHEN (expression) program-statement;

  • OTHERWISE program-statement;

For the most part, the SAS programming statements available in PROC GAMSELECT work the same as they do in the SAS DATA step, as documented in SAS Programmers Guide: Essentials. However, there are several differences:

  • 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 LAG function is not supported.

  • The WHEN and OTHERWISE statements enable you to specify more than one target statement. That is, DO/END groups are not necessary for multiple WHEN statements. 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.

When coding your programming statements, you should avoid defining variables that begin with an underscore (_), because they might conflict with internal variables that PROC GAMSELECT creates. You should avoid operations that would directly modify the variables that appear in the input table, because such operations are not supported for the input data.

You cannot use the programming statements to create a computed variable and then add it to the CLASS statement so that it is used as a classification variable. If you have already specified a variable in the CLASS statement, you should also avoid using it in the programming statements to compute variables with the expectation that the computation would use its levelization results.

Note: The programming statements are not available if you are using the V9 engine.

Last updated: May 14, 2026