A Conceptual View of Arrays

One-Dimensional Array

The following figure is a conceptual representation of two one-dimensional arrays, MISC and MDAY.

start figure
  Arrays   Variables  1      2      3      4      5      6      7      8  MISC  misc1  misc2  misc3  misc4  misc5  misc6  misc7  misc8  1      2      3      4      5      6      7  MDAY  mday1  mday2  mday3  mday4  mday5  mday6  mday7  
end figure

Figure 25.1: One-Dimensional Array

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.

start figure
  First             Second Dimension            Dimension  Expense Categories                      Days of the Week         Total                       1       2       3       4       5       6       7       8 Hotel             1   hotel1  hotel2  hotel3  hotel4  hotel5  hotel6  hotel7  hotel8 Phone             2   phone1  phone2  phone3  phone4  phone5  phone6  phone7  phone8 Pers. Auto        3   peraut1 peraut2 peraut3 peraut4 peraut5 peraut6 peraut7 peraut8 Rental Car        4   carrnt1 carrnt2 carrnt3 carrnt4 carrnt5 carrnt6 carrnt7 carrnt8 Airfare           5   airlin1 airlin2 airlin3 airlin4 airlin5 airlin6 airlin7 airlin8 Dues              6   dues1   dues2   dues3   dues4   dues5   dues6   dues7   dues8 Registration      7   regfee1 regfee2 regfee3 regfee4 regfee5 regfee6 regfee7 regfee8    Fees Other             8   other1  other2  other3  other4  other5  other6  other7  other8 Tips (non-meal)   9   tips1   tips2   tips3   tips4   tips5   tips6   tips7   tips8 Meals            10   meals1  meals2  meals3  meals4  meals5  meals6  meals7  meals8 
end figure

Figure 25.2: Example of a Two-Dimensional Array

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).

SAS 9.1.3 Language Reference. Concepts
SAS 9.1.3 Language Reference: Concepts, Third Edition, Volumes 1 and 2
ISBN: 1590478401
EAN: 2147483647
Year: 2004
Pages: 258

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net