| Examples |
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 from the SQL QUERY COLUMNS window to display the BUILD A COLUMN EXPRESSION window.
![[BUILD A COLUMN EXPRESSION window]](images/ex-bc1.gif)
Select Salary from the Available Columns list. Select the division operator (/) from the list of operators.
![[Sekectung an operator]](images/ex-bc2.gif)
Select <CONSTANT enter value> from the Available Columns list. Enter 50 in the Numeric Constant dialog box. Select to return to the BUILD A COLUMN EXPRESSION window.
![[Numeric Constant dialog box]](images/ex-bc3.gif)
Select the division operator again from the list of operators. Select <CONSTANT enter value> and enter 40 to divide the number of weeks by the number of hours in each week. Select . Select outside the list of operators to dismiss it.
| 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 Column Expression field. A pop-up menu displays a list of choices.
![[Correcting a mistake]](images/ex-bc4.gif)
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 value> from the Available Columns list. Enter 52 as the new constant and select .
| Defining the Column Format and Label |
Select to define the format and label for your new column.
![[Expression Column Attributes dialog box]](images/ex-bc5.gif)
Enter hourly as the alias name. Select the right arrow next to the Format field to choose the format in which the new column will appear.
![[Format Names list]](images/ex-bc6.gif)
Select dollar from the Format Names list. Enter 2 in the Decimal field so that the hourly wage will be displayed to two decimal places. Select .
Enter Hourly Rate in the Label field for the column. Select .
The complete calculated column is displayed in the BUILD A COLUMN EXPRESSION window.
![[Complete column expression]](images/ex-bc7.gif)
Select OK to return to the SQL QUERY COLUMNS window. Note that the new column has automatically been added to the Selected Columns list.
| Viewing Your Output |
To
run your query and view the output in the Output window, select Tools
Run Query
Run
Immediate.
![[Query output]](images/ex-bc8a.gif)
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.