Performing Queries Using SQL |
Ordering
Rows |
Ordering by Multiple Columns
You can also sort rows by the values of two or more columns. Use the ORDER BY clause in the SELECT statement, followed by the column names separated by commas. The ORDER BY clause in this PROC SQL step sorts by values of two columns, SEX and AGE. |
proc sql; select actlevel,sex,age, height*2.54 as CentHgt, weight/2.2 as KgWgt from clinic.admit where actlevel='LOW' order by sex,age; |
This sorting produces the following output: |
ActLevel | Sex | Age | CentHgt | KgWgt |
LOW | F | 22 | 160.02 | 63.18182 |
LOW | F | 28 | 157.48 | 53.63636 |
LOW | F | 31 | 154.94 | 55.90909 |
LOW | F | 49 | 162.56 | 78.18182 |
LOW | M | 34 | 185.42 | 70 |
LOW | M | 51 | 180.34 | 71.81818 |
LOW | M | 60 | 180.34 | 86.81818 |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.