RANK Procedure

BY Statement

Produces a separate set of ranks for each BY group.
Interactions: If the NOTSORTED option is specified on a BY statement, then in-database processing cannot be performed.

Application of a format to any BY variable of the input data set, using a FORMAT statement for example, will prevent in-database processing.

See: BY

Partitioning Observations into Groups Based on Ranks

Ranking Values within BY Groups

Partitioning Observations into Groups Based on Ranks

Syntax

Required Argument

variable
specifies the variable that the procedure uses to form BY groups. You can specify more than one variable. If you do not use the NOTSORTED option in the BY statement, the observations in the data set must either be sorted by all the variables that you specify or be indexed appropriately. Variables in a BY statement are called BY variables.

Optional Arguments

DESCENDING
specifies that the observations are sorted in descending order by the variable that immediately follows the word DESCENDING in the BY statement.
NOTSORTED
specifies that observations are not necessarily sorted in alphabetic or numeric order. The observations are grouped in another way, such as chronological order.
The requirement for ordering or indexing observations according to the values of BY variables is suspended for BY-group processing when you use the NOTSORTED option. In fact, the procedure does not use an index if you specify NOTSORTED. The procedure defines a BY group as a set of contiguous observations that have the same values for all BY variables. If observations with the same values for the BY variables are not contiguous, the procedure treats each contiguous set as a separate BY group.
If you are using a SAS/ACCESS engine, and you specify a BY statement, then the data is always returned in sorted order. If you specify the NOTSORTED option, then it is ignored and in-database processing is performed.