Chapter Contents

Previous

Next
The SORT Procedure

Overview

The SORT procedure sorts observations in a SAS data set by one or more character or numeric variables, either replacing the original data set or creating a new, sorted data set. PROC SORT by itself produces no printed output.

Observations Sorted by the Values of One Variable shows the results of sorting a data set with the most basic form of a PROC SORT step. In this example, PROC SORT replaces the original data set, sorted alphabetically by last name, with a data set that is sorted by employee identification number. The statements that produce the output follow:

proc sort data=employee;
   by idnumber;
run;

proc print data=employee;
run;

Observations Sorted by the Values of One Variable
[HTML Output]  [Listing Output]

Observations Sorted by the Values of Multiple Variables shows the results of a more complicated sort by three variables. The businesses in this example are sorted by town, then by debt from highest amount to lowest amount, then by account number. For an explanation of the program that produces this output, see Reversing the Order of the Sorted Values .

Observations Sorted by the Values of Multiple Variables
[HTML Output]  [Listing Output]

Note:   The sorting capabilities that are described in this chapter are available on all operating environments. In addition, if you use the HOST value of the SAS system option SORTPGM=, you may be able to use other sorting options available only in your operating environment. Refer to the SAS documentation for your operating environment for information on other sorting capabilities. For more information about the SAS system option SORTPGM=, see the chapter on SAS system options in SAS Language Reference: Dictionary.  [cautionend]


Chapter Contents

Previous

Next

Top of Page

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