Specifying a Range of Observations |
You can specify a range of observations with a keyword or by record number by using the POINT option. You can use the range operand with the data management statements DELETE, FIND, LIST, READ, and REPLACE.
You can specify range with any of the following keywords:
specifies all observations.
specifies the current observation.
specifies the next observation or next number of observations.
specifies all observations after the current one.
specifies observations by number, where operand can be one of the following:
Operand |
Example |
a single record number |
point 5 |
a literal giving several record numbers |
point {2 5 10} |
the name of a matrix that contains record numbers |
point p |
an expression in parentheses |
point (p+1) |
If you want to list all observations in the CLASS data set, use the keyword ALL to indicate that the range is all observations. The following example demonstrates the use of this keyword:
> list all; OBS NAME SEX AGE HEIGHT WEIGHT ------ -------- -------- --------- --------- --------- 1 JOYCE F 11.0000 51.3000 50.5000 2 THOMAS M 11.0000 57.5000 85.0000 3 JAMES M 12.0000 57.3000 83.0000 4 JANE F 12.0000 59.8000 84.5000 5 JOHN M 12.0000 59.0000 99.5000 6 LOUISE F 12.0000 56.3000 77.0000 7 ROBERT M 12.0000 64.8000 128.0000 8 ALICE F 13.0000 56.5000 84.0000 9 BARBARA F 13.0000 65.3000 98.0000 10 JEFFREY M 13.0000 62.5000 84.0000 11 CAROL F 14.0000 62.8000 102.5000 12 HENRY M 14.0000 63.5000 102.5000 13 ALFRED M 14.0000 69.0000 112.5000 14 JUDY F 14.0000 64.3000 90.0000 15 JANET F 15.0000 62.5000 112.5000 16 MARY F 15.0000 66.5000 112.0000 17 RONALD M 15.0000 67.0000 133.0000 18 WILLIAM M 15.0000 66.5000 112.0000 19 PHILIP M 16.0000 72.0000 150.0000
Without a range specification, the LIST statement lists only the current observation, which in this example is now the last observation because of the previous LIST statement. Here is the result of using the LIST statement:
> list; OBS NAME SEX AGE HEIGHT WEIGHT ------ -------- -------- --------- --------- --------- 19 PHILIP M 16.0000 72.0000 150.0000
Use the POINT keyword with record numbers to list specific observations. You can follow the keyword POINT with a single record number or with a literal giving several record numbers. Here are two examples:
> list point 5; OBS NAME SEX AGE HEIGHT WEIGHT ------ -------- -------- --------- --------- --------- 5 JOHN M 12.0000 59.0000 99.5000 > list point {2 4 9}; OBS NAME SEX AGE HEIGHT WEIGHT ------ -------- -------- --------- --------- --------- 2 THOMAS M 11.0000 57.5000 85.0000 4 JANE F 12.0000 59.8000 84.5000 9 BARBARA F 13.0000 65.3000 98.0000
You can also indicate the range indirectly by creating a matrix that contains the records you want to list, as in the following example:
> p={2 4 9}; > list point p; OBS NAME SEX AGE HEIGHT WEIGHT ------ -------- -------- --------- --------- --------- 2 THOMAS M 11.0000 57.5000 85.0000 4 JANE F 12.0000 59.8000 84.5000 9 BARBARA F 13.0000 65.3000 98.0000
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 |
|
APPEND |
always at end |
|
DELETE |
current |