Sorting Data

The SORT Procedure

By default, PROC PRINT lists observations in the order in which they appear in your data set. To sort your report based on values of a variable, you must use PROC SORT to sort your data before using the PRINT procedure to create reports from the data.
The SORT procedure does the following:
  • rearranges the observations in a SAS data set
  • creates a new SAS data set that contains the rearranged observations
  • replaces the original SAS data set by default
  • can sort on multiple variables
  • can sort in ascending or descending order
  • treats missing values as the smallest possible values
Note: PROC SORT does not generate printed output.
Syntax, PROC SORT step:
PROC SORT DATA=SAS-data-set ...

Get SAS Certified Specialist Prep Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.