Previous Page | Next Page

The SORT Procedure

BY Statement


Specifies the sorting variables.
Featured in:

Sorting by the Values of Multiple Variables

Sorting in Descending Order

Retaining the First Observation of Each BY Group


BY <DESCENDING> variable-1 <...<DESCENDING> variable-n>;

Required Arguments

variable

specifies the variable by which PROC SORT sorts the observations. PROC SORT first arranges the data set by the values in ascending order, by default, of the first BY variable. PROC SORT then arranges any observations that have the same value of the first BY variable by the values of the second BY variable in ascending order. This sorting continues for every specified BY variable.


Option

DESCENDING

reverses the sort order for the variable that immediately follows in the statement so that observations are sorted from the largest value to the smallest value. The DESCENDING keyword modifies the variable that follows it.

Tip: In a PROC SORT BY statement, the DESCENDING keyword modifies the variable that follows it.
Tip: The THREADS SAS system option is the default as long as the PROC SORT THREADS | NOTHREADS option is unspecified.
Featured in: Sorting in Descending Order

Previous Page | Next Page | Top of Page