Sorting Data |
Instructions |
To sort your data, follow this selection path:Tasks Data Management SortThe Sort a Table window appears.
Sort a Table Window
If the active table is SASUSER.HOUSES, then continue to the next step. Otherwise, select , and then select the SASUSER.HOUSES table. For more information on selecting tables, see Selecting a Table.
If other report selections exist (for example, column name is listed for ), then selectFile Newto clear these selections.
Select from the Sort a Table window. The Specify Output Table window appears.
Specify Output Table Window
An output table enables you to store the sorted table separately from the original table. If you do not select an output table, the sorted table overwrites the original table.
In the Table field, type STYLE as the name of the output table in which you want to store the sorted data. See SAS Tables for details on assigning names to tables.
Note: Replace if existing enables you to replace the data in an existing table with the newly sorted data. If the STYLE table already exists, then you can use this item to store the newly sorted data in place of whatever was currently stored in the STYLE table. Otherwise, you get an error message that states that the STYLE table already exists. You can either enter another name for the table or select Replace if existing to replace the existing data.
You can store the data temporarily or permanently. For this example, store the data temporarily.
To store the sorted data only for the length of the SAS session, select Temporary. The sorted data are stored in a temporary table called WORK.STYLE, which is deleted when you end the SAS session.
To store the sorted data permanently, select Permanent. A list of existing librefs appears.
Select the libref for the location where you want to store the data, for example, the SASUSER libref. The table STYLE is stored in the library whose libref is SASUSER, and remains there until you delete it.
A libref specifies the SAS data library in which you want to store the sorted data. Refer to SAS Data Libraries for more information about librefs.
Select at the bottom of the window. The Sort a Table window reappears.
Select from the Sort a Table window. Select the STYLE column first and the SQFEET column second. For more information on selecting columns, refer to Selecting a Column.
Select from the Sort a Table window. The Select the Ordering of Columns window appears.
Select the Ordering of Columns Window
You can choose to order the data in ascending, descending, or mixed order.Select Mixed ascending and descending order. The BY Column Sort Order window appears.
BY Column Sort Order Window
For the STYLE column, select Ascending order. For the SQFEET column, select Descending order.
SelectRun SubmitThe table is sorted according to the specifications that you indicated. A message appears that indicates that the table was successfully sorted.
Successful Sort Message
To see how the table has been sorted, edit or browse the WORK.STYLE table in a tabular format. The sorted table is shown in the following display.
Refer to Editing and Browsing Data for more information about editing and browsing data.
Sorted Houses Table
The styles of houses are listed alphabetically. Houses with a style of CONDO are first in the table. Within each style, the houses are listed from largest to smallest.
Exiting This Task |
When you are finished looking at your sorted table, selectFile CloseWhen you are ready to return to the WorkPlace menu or move on to another task, follow the directions in Exiting a Task.
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.