By default, many SAS procedures process all the observations in a data set. You can subset observations for processing by adding a WHERE statement to your PROC step. The WHERE statement remains in effect only for the PROC step in which it appears. |
General form, WHERE statement:
WHERE where-expression; where where-expression specifies a condition for selecting observations. The where-expression can be any valid SAS expression. |
For example, the WHERE statement in the PROC PRINT step
below selects only observations where the value of Age is greater
than 30.
proc print data=clinic.admit; var age height weight fee; where age>30; run; |
Symbol | Meaning | Example |
---|---|---|
= or eq | equal to | where name='Jones, C.';
|
^= or ne | not equal to | where temp ne 212;
|
> or gt | greater than | where income>20000;
|
< or lt | less than | where partno lt "BG05";
|
|
greater than or equal to | where id>='1543';
|
<= or le | less than or equal to | where pulse le 85;
|
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
where age<=55 and pulse>75; where area='A' or region='S'; where empnum>1050 and state='NC';
where actlevel='LOW' or actlevel='MOD'; where fee=124.80 or fee=178.20; where actlevel in ('LOW','MOD'); where fee in (124.80,178.20); where (age<=55 and pulse>75) or area='A'; where age<=55 and (pulse>75 or area='A'); |
Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.