Chapter Contents

Previous

Next
SAS SQL Query Window User's Guide

Sorting Your Output

Order By enables you to specify the order in which you want the output sorted. Using the query from the last example, you can change the ordering sequence of the columns in your OUTPUT window. From the SQL QUERY COLUMNS window, select

View
[arrow]
Order By...

[IMAGE]

Move Before displays all columns in the Order By Columns list except the currently chosen one. The currently chosen column(s) will be inserted before the column(s) that you select.
Move After displays all the columns in the Order By Columns list except the currently chosen one. The currently chosen column(s) will be inserted following the column(s) that you select.
Ascending Order changes the ordering sequence of the selected column's values to ascending (lowest value to highest value).
Descending Order changes the ordering sequence of the selected column's values to descending.
Build a Column displays the Build a Column Expression window, which enables you to create your calculated column for use in sorting your output. Use the Build a Column Expression window to create new columns by performing calculations on existing (numeric) columns.


Order By Columns

Select BEGDATE from the list of Available Columns. Select [] to move it to the list of Order By Columns. By default, columns are sorted in ascending order, so the abbreviation ASC appears next to the column name in the Order By Columns list. Select BEGDATE ASC and Descending Order to change the ordering sequence.

[IMAGE]

Select Salary and JOBCODE, and move them to the list of Order By Columns.


Move Columns

Select Salary and Move Before. The Move Columns window appears.

[IMAGE]

Select BEGDATE and OK. The ORDER BY COLUMNS window is displayed with Salary first in the list of Order By Columns.

[IMAGE]

Select OK to return to the SQL QUERY COLUMNS window.

Select

View
[arrow]
Where Conditions for Subset...

The WHERE EXPRESSION window appears. Select Undo four times, until only SALARY LT $18,000 is displayed.

[IMAGE]

Select OK.


Viewing Your Output

To run your query and view the output in the OUTPUT window, select

Tools
[arrow]
Run Query
[arrow]
Run Immediate

[IMAGE]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.