Chapter Contents |
Previous |
Next |
Determining the Number of Elements in an Array Efficiently |
The form of the DIM function is as follows:
DIMn(array-name) |
You can also use the DIM function when you specify the number of elements in the array with an asterisk. Here are some examples of the DIM function:
do i=1 to dim(days);
do i=1 to dim4(days) by 2;
DO WHILE and DO UNTIL Expressions |
data test; array trend{5} x1-x5; input x1-x5 y; do i=1 to 5 while(trend{i}<y); ... more SAS statements ... end; datalines; ... data lines ... ;
Using Variable Lists to Define an Array Quickly |
SAS reserves the following three names for use as variable list names:
_CHARACTER_ | |
_NUMERIC_ | |
_ALL_ |
For example, the following INPUT statement reads in variables X1 through X3 as character values using the $8. informat, and variables X4 through X5 as numeric variables. The following ARRAY statement uses the variable list _CHARACTER_ to include only the character variables in the array. The asterisk indicates that SAS will determine the subscript by counting the variables in the array.
input (X1-X3) ($8.) X4-X5; array item {*} _character_;
You can use the _NUMERIC_ variable in your program if, for example, you need to convert currency. In this application, you do not need to know the variable names. You need only to convert all values to the new currency.
For more information about variable lists, see the ARRAY statement in SAS Language Reference: Dictionary.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.