creates a named, ordered,
list of variables that exists for processing of the current DATA step. Array-name must
be a valid SAS name. Each variable is the name of a variable to be
included in the array. Number-of-variables is
the number of variables listed.
When you place a variable
in an array, the variable can also be accessed by array-name {position},
where position is the position
of the variable in the list (from 1 to number-of-variables).
In this way of accessing the variable is called an array reference,
and the position is known as the subscript of the array reference.
After you list a variable in an ARRAY statement, programming statements
in the same DATA step can use either the original name of the variable
or the array reference.
This documentation
uses braces around the subscript. Parentheses ( ) are
also acceptable, and square brackets [ ] are acceptable
in operating environments that support those characters. Refer to
the documentation for your operating environment to determine the
supported characters.
DO;
... SAS statements ...
END;
treats the enclosed SAS
statements as a unit. A group of statements beginning
with DO and ending with END is called a DO group. DO groups usually
appear in THEN clauses or ELSE statements.
DO index-variable=1 TO number-of-variables-in-array;
... SAS statements ...
END;
is known as an iterative
DO loop. In each execution of the DATA step, an iterative DO loop
is processed repeatedly (is iterated) based on the value of index-variable.
To create an index variable, use a SAS variable name in an iterative
DO statement.
When you use iterative
DO loops for array processing, the value of index-variable usually
starts at 1 and increases by 1 before each iteration of the loop.
When the value becomes greater than the number-of-variables-in-array (usually
the number of variables in the array being processed), SAS stops processing
the loop and proceeds to the next statement in the DATA step.
In array processing,
the SAS statements in an iterative DO loop usually contain array references
whose subscript is the name of the index variable (as in array-name {index-variable}).
In each iteration of the loop, SAS replaces the subscript in the reference
with the index variable's current value. Therefore, successive
iterations of the loop cause SAS to process the statements on the
first variable in the array, then on the second variable, and so on.