Creating List Reports |
Selecting
Observations |
By default, a PROC PRINT step lists all the observations in a data set. You can control which observations are printed by adding a WHERE statement to your PROC PRINT step. |
General form, WHERE statement:
where where-expression specifies a condition for selecting observations. The where-expression can be any valid SAS expression. |
For example, the following WHERE statement 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; Here is the procedure output from the PROC PRINT step with the WHERE statement: |
Obs | Age | Height | Weight | Fee |
2 | 34 | 66 | 152 | 124.80 |
3 | 31 | 61 | 123 | 149.75 |
4 | 43 | 63 | 137 | 149.75 |
5 | 51 | 71 | 158 | 124.80 |
7 | 32 | 67 | 151 | 149.75 |
8 | 35 | 70 | 173 | 149.75 |
9 | 34 | 73 | 154 | 124.80 |
10 | 49 | 64 | 172 | 124.80 |
11 | 44 | 66 | 140 | 149.75 |
14 | 40 | 69 | 163 | 124.80 |
15 | 47 | 72 | 173 | 124.80 |
16 | 60 | 71 | 191 | 149.75 |
17 | 43 | 65 | 123 | 124.80 |
20 | 41 | 67 | 141 | 149.75 |
21 | 54 | 71 | 183 | 149.75 |
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"; |
>= or ge |
greater than or equal to | where id>='1543'; |
<= or le |
less than or equal to | where pulse le 85; |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.