Previous Page | Next Page

Sorting Data

Sorting Data


Instructions

  1. To sort your data, follow this selection path:Tasks [arrow] Data Management [arrow] SortThe Sort a Table window appears.

    Sort a Table Window

    [Sort a Table Window]

  2. If the active table is SASUSER.HOUSES, then continue to the next step. Otherwise, select Table, and then select the SASUSER.HOUSES table. For more information on selecting tables, see Selecting a Table.

  3. If other report selections exist (for example, column name is listed for Sort by columns), then selectFile [arrow] Newto clear these selections.

  4. Select Output table from the Sort a Table window. The Specify Output Table window appears.

    Specify Output Table Window

    [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.

  5. 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.  [cautionend]

  6. 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.

  7. Select OK at the bottom of the window. The Sort a Table window reappears.

  8. Select Sort by columns 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.

  9. Select Ordering of columns from the Sort a Table window. The Select the Ordering of Columns window appears.

    Select the Ordering of Columns Window

    [Select the Ordering of Columns Window]

    You can choose to order the data in ascending, descending, or mixed order.
  10. Select Mixed ascending and descending order. The BY Column Sort Order window appears.

    BY Column Sort Order Window

    [BY Column Sort Order Window]

  11. For the STYLE column, select Ascending order. For the SQFEET column, select Descending order.

  12. Select OK. The Sort a Table window reappears.

  13. SelectRun [arrow] 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

    [Successful Sort Message]

  14. Select Goback to return to the Sort a Table window

  15. 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

    [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 [arrow] CloseWhen you are ready to return to the WorkPlace menu or move on to another task, follow the directions in Exiting a Task.

Previous Page | Next Page | Top of Page