LIST Statement |
The LIST statement displays observations of a data set.
The arguments to the LIST statement are as follows:
specifies a range of observations.
specifies a set of variables.
is an expression that selects certain observations.
The LIST statement prints selected observations of a data set. If all data values for variables in the VAR clause fit on a single line, values are displayed in columns headed by the variable names. Each record occupies a separate line. If the data values do not fit on a single line, values from each record are grouped into paragraphs. Each element in the paragraph has the form name=value.
You can use any of the following keywords for range:
specifies all observations.
specifies the current observation (this is the default for the LIST statement).
specifies the next observation or the next number of observations.
specifies all observations after the current one.
specifies observations specified by number, where value can be one of the following:
Value |
Example |
---|---|
A single record number |
point 5 |
A literal that contains several |
point {2 5 10} |
record numbers |
|
The name of a matrix |
point p |
that contains record numbers |
|
An expression in parentheses |
point (p+1) |
If the current data set has an index in use (see the INDEX statement), the POINT option is invalid.
You can specify a set of variables to use with the VAR clause. The operand can be specified as one of the following:
a literal that contains variable names
the name of a matrix that contains variable names
an expression in parentheses that yields variable names
one of the keywords described in the following list:
for all variables
for all character variables
for all numeric variables
The following examples show each possible way you can use the VAR clause:
var {x1 x5 x9}; /* a literal matrix of names */ var x; /* a matrix that contains the names */ var("x1":"x9"); /* an expression */ var _all_; /* a keyword */
The WHERE clause conditionally selects observations, within the range specification, according to conditions given in the clause. The general form of the WHERE clause is
The arguments to the WHERE clause are as follows:
is a variable in the SAS data set.
is any one of the following comparison operators:
less than
less than or equal to
equal to
greater than
greater than or equal to
not equal to
contains a given string
does not contain a given string
begins with a given string
sounds like or is spelled like a given string
is a literal value, a matrix name, or an expression in parentheses.
WHERE comparison arguments can be matrices. For the following operators, the WHERE clause succeeds if all the elements in the matrix satisfy the condition:
= ? < <= > >= |
For the following operators, the WHERE clause succeeds if any of the elements in the matrix satisfy the condition:
= ? =: =* |
Logical expressions can be specified within the WHERE clause by using the AND (&) and OR (|) operators. The general form is as follows:
clause & clause |
(for an AND clause) |
|
clause | clause |
(for an OR clause) |
where clause can be a comparison, a parenthesized clause, or a logical expression clause that is evaluated by using operator precedence.
Note: The expression on the left-hand side refers to values of the data set variables and the expression on the right-hand side refers to matrix values.
The following examples demonstrate the use of the LIST statement. The output is not shown.
data class; set sashelp.class; run; proc iml; use 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 */ list point (10:15); /* lists observations 10 through 15 */ close class;