SORT Procedure

BY Statement

Specifies the sorting variables.
Sorting by the Values of Multiple Variables

Sorting in Descending Order

Retaining the First Observation of Each BY Group

Syntax

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

Required Argument

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.

Optional Argument

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.
Tips:In a PROC SORT BY statement, the DESCENDING keyword modifies the variable that follows it.

The THREADS SAS system option is the default as long as the PROC SORT THREADS | NOTHREADS option is unspecified.