Language Reference |
reads observations from a data set
Operand | Example |
a single record number | point 5 |
a literal giving several | point {2 5 10} |
record numbers | |
the name of a matrix | point p |
containing record numbers | |
an expression in parentheses | point (p+1) |
var {time1 time5 time9}; /* a literal giving the variables */ var time; /* a matrix containing the names */ var('time1':'time9'); /* 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 as follows:
^= ^? < <= > >= |
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
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.
You can specify ROWNAME= and COLNAME= matrices as part of the INTO clause. The COLNAME= matrix specifies the name of a new character matrix to be created. This COLNAME= matrix is created in addition to the target matrix of the INTO clause and contains variable names from the input data set corresponding to columns of the target matrix. The COLNAME= matrix has dimension nvar, where nvar is the number of variables contributing to the target matrix.
The ROWNAME= option specifies the name of a character variable in the input data set. The values of this variable are put in a character matrix with the same name as the variable. This matrix has the dimension nobs, where nobs is the number of observations in the range of the READ statement.
The range, VAR, WHERE, and INTO clauses are all optional and can be specified in any order.
Row and column names created via a READ statement are permanently associated with the INTO matrix. You do not need to use a MATTRIB statement to get this association.
For example, to read all observations from the data set variables NAME and AGE, use a READ statement with the VAR clause and the keyword ALL for the range operand. This creates two IML variables with the same names as the data set variables. Here is the statement:
read all var{name age};To read all variables for the 23rd observation only, use the following statement:
read point 23;To read the data set variables NAME and ADDR for all observations with a STATE value of
NJ
, use the following statement:
read all var{name addr} where(state="NJ");See Chapter 6 for further information.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.