Syntax for Defining and Referencing an Array

To define a simple or a multidimensional array, use the ARRAY statement. The ARRAY statement has the following form:
ARRAY array-name {number-of-elements} <$> <length> <array-elements> <(initial-value-list)>;
where
array-name
is a SAS name that identifies the group of variables.
number-of-elements
is the number of variables in the group. You must enclose this value in either parentheses (), braces {}, or brackets [].
$
specifies that the elements in the array are character elements.
length
specifies the length of the elements in the array that have not been previously assigned a length.
array-elements
is a list of the names of the variables in the group. All variables that are defined in a given array must be of the same type, either all character or all numeric.
initial-value-list
is a list of the initial values for the corresponding elements in the array.
For complete information, see the ARRAY Statement in SAS Statements: Reference.
To reference an array that was previously defined in the same DATA step, use an Array Reference statement. An array reference has the following form:
array-name {subscript}
where
array-name
is the name of an array that was previously defined with an ARRAY statement in the same DATA step.
subscript
specifies the subscript, which can be a numeric constant, the name of a variable whose value is the number, a SAS numeric expression, or an asterisk (*).
Note: Subscripts in SAS are 1-based by default, and not 0-based as they are in some other programming languages.
For complete information, see the Array Reference statement in the SAS Statements: Reference.