SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating List Reports
Selecting Observations


Specifying Compound WHERE Expressions

You can also use WHERE statements to select a subset of observations based on multiple conditions. To link a sequence of expressions into compound expressions, you use logical operators, including the following:


Operator Meaning
AND     & and, both. If both expressions are true, then the compound expression is true.
OR     | or, either. If either expression is true, then the compound expression is true.


Examples of WHERE Statements
  • You can use compound expressions like these in your WHERE statements:
      where age<=55 and pulse>75;
      where area='A' or region='S'; 
      where ID>1050 and state='NC';
  • When you test for multiple values of the same variable, you specify the variable name in each expression:
      where actlevel='LOW' or actlevel='MOD';
      where fee=124.80 or fee=178.20; 
  • You can use the IN operator as a convenient alternative:
      where actlevel in ('LOW','MOD'); 
      where fee in (124.80,178.20); 
  • To control the way compound expressions are evaluated, you can use parentheses:
      where (age<=55 and pulse>75) or area='A';
      where age<=55 and (pulse>75 or area='A');


back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement