Working with SAS Data Sets


Process a Range of Observations

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:

ALL

specifies all observations.

CURRENT

specifies the current observation.

NEXT <number>

specifies the next observation or the next number of observations.

AFTER

specifies all observations after the current one.

POINT value

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

read point 5

A literal that contains several

read point {2 5 10}

record numbers

 

The name of a matrix that

p=1:5; read point p;

contains record numbers

 

An expression in parentheses

read point (p+1);


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.