Misc contains eight elements, the variables Misc1 through Misc8. To reference the data
in these variables, use the form Misc{n}, where n is the element number in the array. For
example, Misc{6} is the sixth element in the array.
Mday contains seven elements, the variables Mday1 through Mday7. Mday{3} is the
third element in the array.
Two-Dimensional Array
The following figure is a conceptual representation of the two-dimensional array
Expenses.
Figure 25.2 Example of a Two-Dimensional Array
Ho t e l
P h o n e
P e r s . A u t o
Re n t a l Ca r
Ai r f a r e
Du e s
Re g i s t r a t i o n
F e e s
Ot h e r
T i p s ( n o n - me a l )
Me a l s
1
h o t e l 1
p h o n e 1
p e r a u t 1
c a r r n t 1
a i r l i n 1
d u e s 1
r e g f e e 1
o t h e r 1
t i p s 1
me a l s 1
2
h o t e l 2
p h o n e 2
p e r a u t 2
c a r r n t 2
a i r l i n 2
d u e s 2
r e g f e e 2
o t h e r 2
t i p s 2
me a l s 2
3
h o t e l 3
p h o n e 3
p e r a u t 3
c a r r n t 3
a i r l i n 3
d u e s 3
r e g f e e 3
o t h e r 3
t i p s 3
me a l s 3
4
h o t e l 4
p h o n e 4
p e r a u t 4
c a r r n t 4
a i r l i n 4
d u e s 4
r e g f e e 4
o t h e r 4
t i p s 4
me a l s 4
5
h o t e l 5
p h o n e 5
p e r a u t 5
c a r r n t 5
a i r l i n 5
d u e s 5
r e g f e e 5
o t h e r 5
t i p s 5
me a l s 5
6
h o t e l 6
p h o n e 6
p e r a u t 6
c a r r n t 6
a i r l i n 6
d u e s 6
r e g f e e 6
o t h e r 6
t i p s 6
me a l s 6
7
h o t e l 7
p h o n e 7
p e r a u t 7
c a r r n t 7
a i r l i n 7
d u e s 7
r e g f e e 7
o t h e r 7
t i p s 7
me a l s 7
8
h o t e l 8
p h o n e 8
p e r a u t 8
c a r r n t 8
a i r l i n 8
d u e s 8
r e g f e e 8
o t h e r 8
t i p s 8
me a l s 8
1
2
3
4
5
6
7
8
9
10
First
Dimension
Expense
Categories
Second
Dimension
Days of the Week Total
The Expenses array contains ten groups of eight variables each. The ten groups (expense
categories) comprise the first dimension of the array, and the eight variables (days of the
week) comprise the second dimension. To reference the data in the array variables, use
the form Expenses{m,n}, where m is the element number in the first dimension of the
array, and n is the element number in the second dimension of the array. Expenses{6,4}
references the value of dues for the fourth day (the variable is Dues4).
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.
Syntax for Defining and Referencing an Array 567

Get SAS 9.4 Language Reference, 6th 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.