Allowable expressions in the WHERE statement
· No variables created in the data step can be used in a WHERE statement. I think of it this way:
At the time of expression evaluation you have not input any observation into RAM yet.
Since you have not brought an observation in, you can not operate on it with an assignment statement.
· Only "simple" expressions are allowed. Things like arithmetic (e.g., + - * /) and logical comparisons are allowed (e.g., > = And Or). The full list of operators is in SL:R Table 9.3.
Other useful forms:
Use the IN operator to check whether a variable's value is equal to one of a list
WHERE Gender IN ('M', 'F');
Two other "forms" are legal in a WHERE statement:
The BETWEEN-AND operator:
WHERE Weight BETWEEN 100 AND 200;
The CONTAINS operator:
WHERE diagnose CONTAINS 'depres';
See C&P Chapter 3, WHERE statement operators