|
Chapter Contents |
Previous |
Next |
| Language Reference |
replaces values in observations and updates observations
The inputs to the REPLACE statement are as follows:
For example, the statements below cause all
occurrences of ILL to be replaced
by IL for the variable STATE:
state="IL";
replace all var{state} where(state="ILL");
You can specify a range of observations with a keyword or by record number using the POINT option. You can use any of the following keywords to specify a range:
| 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) |
You can specify a set of variables to use with the VAR clause. The variables argument can have the following values:
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
In the statement above,
| = ? < <= > >= |
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 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 using operator precedence.
Note: The expression on the left-hand side refers to values of the data setvariables, and the expression on the right-hand side refers to matrix values.
The code statement below replaces all variables in the current observation:
replace;
|
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.