Creating List Reports |
Sorting
Data |
By default, PROC PRINT lists observations in the order that they appear in your data set. To sort your data based on values of a variable, you must use PROC SORT to sort your data before using other procedures to create reports from the data. |
General form, simple PROC SORT step:
where
|
In the following program, the PROC SORT step sorts the permanent
SAS data set Clinic.Admit by the values of the variable
Weight and creates the temporary SAS data set
Wgtadmit. Then the PROC PRINT step prints the
Wgtadmit data set.
proc sort data=clinic.admit out=wgtadmit; by weight; run; proc print data=wgtadmit; var age height weight fee; where age>30; sum fee; run; The report displays observations in ascending order of weight. |
Obs | Age | Height | Weight | Fee |
2 | 31 | 61 | 123 | 149.75 |
3 | 43 | 65 | 123 | 124.80 |
4 | 43 | 63 | 137 | 149.75 |
6 | 44 | 66 | 140 | 149.75 |
7 | 41 | 67 | 141 | 149.75 |
9 | 32 | 67 | 151 | 149.75 |
10 | 34 | 66 | 152 | 124.80 |
11 | 34 | 73 | 154 | 124.80 |
12 | 51 | 71 | 158 | 124.80 |
13 | 40 | 69 | 163 | 124.80 |
15 | 49 | 64 | 172 | 124.80 |
16 | 35 | 70 | 173 | 149.75 |
17 | 47 | 72 | 173 | 124.80 |
18 | 54 | 71 | 183 | 149.75 |
20 | 60 | 71 | 191 | 149.75 |
2071.60 |
Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.