Referring to variables using SAS variable lists
When a series of variables is being referred to, the use of an abbreviated variable list can save a great deal of time. SAS supports three types of abbreviated variable lists, numbered range lists (specified using one dash), name range lists (specified using two dashes), and special name lists.
1. Numbered range lists
VAR1-VAR5 is equivalent to VAR1 VAR2 VAR3 VAR4 VAR5. If you use this type of variable list then all variables must exist.
2. Name range lists
X--A refers to all variables between X and A inclusive, according to the order of the variables in the PDV (program data vector). That is, according to the SAS internal variable order.
X-numeric-A refers to all numeric variables between X and A inclusive and X-character-A refers to all character variables between X and A inclusive.
The SAS internal sort order is the order in which SAS encountered the variables in the data step which created the SAS data set. If the SAS data set was created by, for example, reading a text file, the internal order will be the order in which the variables were read in. This makes it easy to access, for example, the variables representing a series of questions in a questionnaire.
The internal order of the variables can be determined using the POSITION option on PROC CONTENTS.
proc contents data=hit.cases position;
This will result in one list of variables in alphabetical order (the default ordering for PROC CONTENTS) and a second list according to the internal order.
Variables in the VAR windows (type, for example, var hit.cases in the command line) will, by default, be ordered by the internal order.
3. Special SAS name lists
These include all variables of a particular type. For example _CHARACTER_, _NUMERIC_, and _ALL_.
Examples of usage
var pnr name week1-week12;
SAS Language, version 6, first edition, pages 111-113.