Valid in: | DATA step |
Category: | Information |
Type: | Declarative |
array simple{3} red green yellow;
An array with more than one dimension is known as a multidimensional array. You can have any number of dimensions in a multidimensional array. For example, a two-dimensional array provides row and column arrangement of array elements. SAS places variables into a two-dimensional array by filling all rows in order, beginning at the upper left corner of the array (known as row-major order). This statement defines a two-dimensional array with five rows and three columns:
array x{5,3} score1-score15;
To reduce the computational time that is needed for subscript evaluation, specify a lower bound of 0.
array x{5,3} score1-score15;
As an alternative, the following ARRAY statement is a longhand version of the previous example:
array x{1:5,1:3} score1-score15;
_NUMERIC_ specifies all numeric variables.
_CHARACTER_ specifies all character variables.
_ALL_ specifies all variables.
They do not have names. Refer to temporary data elements by the array name and dimension.
They do not appear in the output data set.
You cannot use the special subscript asterisk (*) to refer to all the elements.
Temporary data element values are always automatically retained, rather than being reset to missing at the beginning of the next iteration of the DATA step.
Arrays of temporary elements are useful when the only purpose for creating an array is to perform a calculation. To preserve the result of the calculation, assign it to a variable. You can improve performance time by using temporary data elements.
Elements and values are matched by position. If there are more array elements than initial values, the remaining array elements receive missing values and SAS issues a warning.
You can separate the values in the initial value list with either a comma or a blank space.
You can also use a shorthand notation for specifying a range of sequential integers. The increment is always +1.
If you have not previously specified the attributes of the array elements (such as length or type), the attributes of any initial values that you specify are automatically assigned to the corresponding array element. Initial values are retained until a new value is assigned to the array element.
When any (or all) elements are assigned initial values, all elements behave as if they were named on a RETAIN statement.
ARRAY x{10} x1-x10 (10*5);
ARRAY x{10} x1-x10 (5*(5 5));
ARRAY x{10} x1-x10 (5 5 3*(5 5) 5 5);
ARRAY x{10} x1-x10 (2*(5 5) 5 5 2*(5 5));
ARRAY x{10} x1-x10 (2*(5 2*(5 5)));