Chapter Contents |
Previous |
Next |
Definition |
With the exception of the numbered range list, you refer to the variables in a variable list in the same order that SAS uses to keep track of the variables. SAS keeps track of active variables in the order that the compiler encounters them within a DATA step, whether they are read from existing data sets, an external file, or created in the step. In a numbered range list, you can refer to variables that were created in any order, provided that their names have the same prefix.
You can use variable lists in many SAS statements and data set options, including those that define variables. However, they are especially useful after you define all of the variables in your SAS program because they provide a quick way to reference existing groups of data.
Note: Only the numbered range
list is allowed in the RENAME= option.
Numbered Range Lists |
x1,x2,x3,...,xn x1-xn
In a numbered range list, you can begin with any number and end with any number as long as you do not violate the rules for user-supplied variable names and the numbers are consecutive.
For example, suppose you decide to give some of your numeric variables sequential names, as in VAR1, VAR2, and so on. Then, you can write an INPUT statement as follows:
input idnum name $ var1-var3;
Note that the character variable NAME is not included in the abbreviated list.
Name Range Lists |
This variable list ... | includes ... | |
---|---|---|
x--a |
all variables ordered as they are in the program data vector, from X to A inclusive. | |
x-numeric-a |
all numeric variables from X to A inclusive. | |
x-character-a |
all character variables from X to A inclusive. |
For example, consider the following INPUT statement:
input idnum name $ weight pulse chins;
In later statements you can use these variable lists:
/* keeps only the numeric variables idnum, weight, and pulse */ keep idnum-numeric-pulse; /* keeps the consecutive variables name, weight, and pulse */ keep name--pulse;
Name Prefix Lists |
sum(of SALES:)tells SAS to calculate the sum of all the variables that begin with "SALES," such as SALES_JAN, SALES_FEB, and SALES_MAR.
Special SAS Name Lists |
Special SAS name lists include
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.