Chapter Contents |
Previous |
Next |
SAS Component Language: Reference |
declare num Factor[5];This DECLARE statement also produces variables FACTOR[1] through FACTOR[5].
Because you must use the DECLARE statement to declare dynamic arrays, the only way to reference the elements of a dynamic array is with subscripting. However, you cannot reference the elements of a dynamic array until you have created the array. See Creating and Initializing Dynamic Arrays for more information.
You can also use subscripting to refer to elements of an array that is declared with the ARRAY statement. For example, you can use MONTH[1] and MONTH[4] to refer to the first and fourth elements of an array that is declared with the following statement:
array month[5] $;
If the array is declared with an ARRAY statement that does not assign individual names to the array elements (as shown in this example), then you can also refer to these array elements as MONTH1 and MONTH4.
If the ARRAY statement assigns names to the individual array elements, then you can also use those names to refer to the array elements. For example, if you declare your array with the following statement, then you can refer to the elements in the array using the names JAN, FEB, and MAR:
array month[3] $ jan feb mar;
Grouping Variables That Have Sequential Names |
array score[4];
Note: If the variables do not already exist as window
variables, then SCL defines new, nonwindow, numeric variables with those names.
Grouping the variables into an array is useful when your program needs to apply the same operations to all of the variables. See Repeating an Action for Variables in an Array for more information.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.