data one;
array state{*} &list;
more SAS statements
data two;
array state{*} &list;
more SAS statements
Variations on Basic Array Processing
Determining the Number of Elements in an Array Efficiently
The DIM function in the iterative DO statement returns the number of elements in a one-
dimensional array or the number of elements in a specified dimension of a
multidimensional array, when the lower bound of the dimension is 1. Use the DIM
function to avoid changing the upper bound of an iterative DO group each time you
change the number of elements in the array.
The form of the DIM function is as follows:
where n is the specified dimension that has a default value of 1.
You can also use the DIM function when you specify the number of elements in the
array with an asterisk. Here are some examples of the DIM function:
do i=1 to dim(days);
do i=1 to dim4(days) by 2;
DO WHILE and DO UNTIL Expressions
Arrays are often processed in iterative DO loops that use the array reference in a DO
WHILE or DO UNTIL expression. In this example, the iterative DO loop processes the
elements of the array named Trend.
data test;
array trend{5} x1-x5;
input x1-x5 y;
do i=1 to 5 while(trend{i}<y);
more SAS statements
data lines
Using Variable Lists to Define an Array Quickly
SAS reserves the following three names for use as variable list names:
538 Chapter 23 Array Processing

Get SAS 9.4 Language Reference, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.