Chapter Contents

Previous

Next

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} <list-of-variables>;

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 parentheses, braces, or brackets.

list-of-variables
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.

For complete information about the ARRAY statement, see SAS Language Reference: Dictionary.

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.  [cautionend]

For complete information about the Array Reference statement, see "Statements" in SAS Language Reference: Dictionary.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.