Chapter Contents |
Previous |
Next |
Syntax |
WHERE where-expression-1 logical-operator where-expression-n ;
AND | combines two conditions by finding observations that
satisfy both conditions. For example:
where skill eq 'cobol' and years eq 4; |
OR | combines two conditions by finding observations that
satisfy either condition or both. For example:
where skill eq 'cobol' or years eq 4; |
NOT | modifies a condition by finding the complement of
the specified criteria. You can use the NOT logical operator in combination
with any SAS and WHERE expression operator. And you can combine the NOT operator
with AND and OR. For example:
where skill not eq 'cobol' or years not eq 4; |
Symbol | Mnemonic Equivalent |
---|---|
& | AND |
! or | or ¦ | OR |
^ or ~ or ¬ | NOT |
Processing Compound Expressions |
For a complete discussion of the rules for evaluating compound expressions, see Order of Evaluation in Compound Expressions.
Using Parentheses to Control Order of Evaluation |
For example, suppose you want a list of all the Canadian sites that have both SAS/GRAPH and SAS/FSP software, so you issue the following expression:
where product='GRAPH' or product='FSP' and country='Canada';
The result, however, includes all sites that license SAS/GRAPH software along with the Canadian sites that license SAS/FSP software. To obtain the correct results, you can use parentheses, which causes SAS to evaluate the comparisons within the parentheses first, providing a list of sites with either product licenses, then the result is used for the remaining condition:
where (product='GRAPH' or product='FSP') and country='Canada';
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.