The following SAS/IML statements enable you to specify a range of observations to process:
You can specify a range of observations by using one of the following keywords:
specifies all observations.
specifies the current observation.
specifies the next observation or the next number of observations.
specifies all observations after the current one.
specifies observations by number.
Usually the ALL keyword is used, but the default value for the range is CURRENT. The NEXT and POINT keywords support values. The values can be literals, expressions, and numeric matrices, as shown in Table 7.2.
Table 7.2: Values Supported by the POINT and NEXT Keywords
Value |
Example |
---|---|
A single record number |
|
A literal that contains several |
|
record numbers |
|
The name of a matrix that |
|
contains record numbers |
|
An expression in parentheses |
|
If the current data set has an index in use (see the INDEX statement), the POINT keyword is invalid.
The following statements specify ranges of observations to the LIST statement. The output is not shown.
proc iml; use Sashelp.class; list all; /* lists whole data set */ list; /* lists current observation */ list var{name age}; /* lists NAME and AGE in current obs */ list all where(age<=13); /* lists all obs where condition holds */ list next; /* lists next observation */ list point 18; /* lists observation 18 */ range = 10:15; list point range; /* lists observations 10 through 15 */ close Sashelp.class;
The range operand is usually listed first when you are using the access statements DELETE, FIND, LIST, READ, and REPLACE. The following table shows access statements and their default ranges:
Statement |
Default Range |
---|---|
LIST |
Current |
READ |
Current |
FIND |
All |
REPLACE |
Current |
DELETE |
Current |
The APPEND statement does not support a range operand; new observations are always appended to the end of a data set.