Chapter Contents |
Previous |
Next |
SAS SQL Query Window User's Guide |
Using the query from the last example, you can create a new column that computes the hourly wage for each salary.
Build a Column Expression |
Select
Build a Column
from the SQL QUERY COLUMNS window to display the BUILD
A COLUMN EXPRESSION window.
Select
Salary
from the Available Columns window. Select
the division operator
(/)
from the list of operators.
Select
<CONSTANT enter value>
from the Available Columns
window. Enter
50
in the Numeric Constant dialog. Select
OK
to return to the BUILD A COLUMN EXPRESSION window.
Select the division operator again
from the list of operators, and enter
40 to divide the number of weeks by the number of hours in each week. Click
OK
. Click outside the operator box to dismiss the list of operators.
Correcting Your Mistakes |
You realize that you have made a mistake
and that you want to
divide Salary by 52, the number of weeks in a year. Select
50
in the WHERE expression. A pop-up menu displays a list of choices.
Select
Replace
from the pop-up menu. The BUILD A COLUMN
EXPRESSION window displays "Select from Available Columns to replace this
value."
Select
<CONSTANT Enter Values>
from the list of Available
Columns. Enter
52
as the new constant.
Defining the Column Format and Label |
Select
Column Attributes
to define the format and label for your new column.
Enter
hourly
as the alias name. Select the [→] next to the
Format
field to choose the format
in which the new column will appear.
Select
dollar
from the list of Format Names. Enter
2
in the
Decimal:
field so that the hourly wage will be displayed
to two decimal places. Select
OK
.
Enter
Hourly Rate
in the
Label
field for the column.
Select
OK
.
The complete calculated column is displayed in the Column Expression window.
Select
OK
to return to the SQL QUERY COLUMNS window.
Viewing Your Output |
To run your query and view the output in the OUTPUT window, select
Tools | Run Query | Run Immediate |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.