This chapter continues with the presentation of topics that are useful in preparing a data set for analysis. The topics here are designed to provide greater flexibility in constructing SAS programs. Using these techniques can simplify coding for tasks that involve repeated or related observations.
ARRAY statement provides a method for placing a series of observations into a single variable called an array. Often these variables are referenced as part of a
DO loop, which is a technique for iterating through a set of data. (
DO loops are presented in the following section of this chapter.) A simplified syntax for SAS arrays is the following:
ARRAY ARRAY-NAME(SUBSCRIPT) <$> ARRAY-VALUES
One-dimensional arrays are specified with an
ARRAY statement, such as
ARRAY TIME(1:6) TIME1-TIME6;
ARRAY statement creates a one-dimensional array called
TIME1 with an index value indicated in a parenthesis so
TIME(1)=TIME1, TIME(2)=TIME2, and so on. In this case, six values are assigned to the values
TIME(6). Here are some more ways to create an
ARRAY TIME(6) TIME1-TIME6;
The result is the same as the previous example.
ARRAY TIME(0:5) A B C D E F;
TIME(0)=A, TIME(1)=B, and ...