The GA Procedure

Programming Statements

This section lists the programming statements used to initialize the model, code the objective function, and control the optimization process in the GA procedure. It documents the differences between programming statements in the GA procedure and programmming statements in the DATA step. The syntax of programming statements used in PROC GA is identical to that of programming statements used in the FCMP procedure.

Most of the programming statements that can be used in the SAS DATA step can also be used in the GA procedure. See the SAS Language Reference: Dictionary or BASE SAS documentation for a description of the SAS programming statements.

variable = expression;
variable + expression;
arrayvar[subscript] = expression;
ABORT;
CALL subroutine < ( parameter-1 <, ...parameter-n > ) >;
DELETE;
DO program-statements; END;
DO variable = expression TO expression <BY expression>;
            program-statements; END;
DO WHILE expression ;
            program-statements; END;
DO UNTIL expression ;
            program-statements; END;
GOTO statement_label ;
IF expression THEN program-statement;
        <ELSE program-statement>;
PUT < variable(s)> <@ | @@> ;
RETURN <(expression)>;
SELECT <(select-expression)>;
        WHEN-1 (expression-1 <...,expression-n>)program-statement ;
        <WHEN-n (expression-1 <...,expression-n>)program-statement ;>
        <OTHERWISE program-statement ;>
STOP;
SUBSTR( variable, index, length ) = expression;

For the most part, the SAS programming statements work as they do in the SAS DATA step as documented in the SAS Language Reference: Dictionary. However, there are several differences that should be noted.

do i = 1,2,3;

is supported; however,

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

is not.

  • The PUT statement, used mostly for program debugging in PROC GA, supports only some of the features of the DATA step PUT statement, and has some new features that the DATA step PUT statement does not:
    • The PROC GA PUT statement does not support line pointers, factored lists, iteration factors, overprinting, _INFILE_, the colon (:) format modifier, or "$".
    • The PROC GA PUT statement does support expressions, but the expression must be enclosed inside parentheses. For example, the following statement displays the square root of x:   put (sqrt(x));
    • The PROC GA PUT statement permits an array name without subscripts. The statement PUT A; prints all the elements of array A. The statement PUT A=; prints the elements of array A with each value labeled with the name of the element variable.
    • The PROC GA PUT statement supports the print item _PDV_ to print a formatted listing of all variables in the program. For example, the following statement displays a more readable listing of the variables than the _all_ print item:   put _pdv_;
  • The WHEN and OTHERWISE statements permit 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; 

  • Previous Page | Next Page | Top of Page