| Performing Queries Using SQL |
| Selecting
Columns |
| After the PROC SQL statement, you write the SELECT statement.
You use a SELECT clause to specify the columns to be selected.
After the keyword SELECT, list column names, separated by commas.
The SELECT clause below specifies the columns |
proc sql;
select id,lastname,netpay,grosspay,
grosspay*.06 as bonus
from emplib.payroll
where netpay>25000
order by lastname;
|
| Defining New Columns
The column named Use the keyword AS to create a new column that will be assigned the value of the preceding column or expression. |
proc sql;
select id,lastname,netpay,grosspay,
grosspay*.06 as bonus
from emplib.payroll
where netpay>25000
order by lastname;
|
Notice that bonus appears in lowercase, exactly
as it is specified in the SELECT clause. |
| 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.