Performing Queries Using SQL |
Specifying Subsetting
Criteria |
To subset data based on a condition, you use a WHERE clause in the SELECT statement. As in the WHERE statement and the WHERE command, the expression in the WHERE clause can be any valid SAS expression. |
proc sql; select id, lastname, netpay,grosspay, grosspay*.06 as bonus from emplib.payroll where netpay>25000 order by lastname; |
The WHERE clause above selects rows where the value of the
column NetPay is greater than 25,000. |
ID | LastName | NetPay | GrossPay | bonus |
1002 | BOWMAN | $29,048.50 | $42,120.33 | 2527.22 |
1007 | BROWN | $37,049.40 | $53,927.72 | 3235.663 |
1049 | FERNANDEZ | $25,169.63 | $35,956.61 | 2157.397 |
1006 | GARRETT | $34,013.88 | $47,241.50 | 2834.49 |
1077 | GIBSON | $41,553.94 | $61,108.73 | 3666.524 |
1008 | HERNAND | $54,189.70 | $78,575.07 | 4714.504 |
1009 | JONES | $44,128.90 | $63,986.91 | 3839.215 |
1005 | KNAPP | $33,122.70 | $48,027.99 | 2881.679 |
1012 | QUINTERO | $51,888.53 | $79,828.51 | 4789.711 |
1015 | SCHOLL | $27,640.80 | $40,079.23 | 2404.754 |
1010 | SMITH | $37,331.48 | $54,899.24 | 3293.954 |
1011 | VAN HOTTEN | $29,053.05 | $43,688.80 | 2621.328 |
1017 | WAGGONNER | $26,484.02 | $38,550.25 | 2313.015 |
1001 | WATERHOUSE | $32,140.60 | $46,603.94 | 2796.236 |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.