SORT Procedure

Requirement: BY statement
Tips: You can use the ATTRIB, FORMAT, LABEL, and WHERE statements with the PROC SORT procedure. For more information, see Statements with the Same Function in Multiple Procedures. You can also use any global statement. For a list, see Global Statements in SAS Statements: Reference.

For in-database processing to occur, your data must reside within a supported version of a DBMS that has been properly configured for SAS in-database processing. For more information, see In-Database Processing: PROC SORT.

See: SORT Procedure: Windows in SAS Companion for Windows, SORT Procedure: z/OS in SAS Companion for z/OS, SORT Procedure: UNIX in SAS Companion for UNIX Environments.

Syntax

PROC SORT <collating-sequence-option> <other option(s)>;
BY <DESCENDING> variable-1 <…<DESCENDING> variable-n>;
KEY variable(s) </ option>;

Table of Procedure Tasks

Statement Task Example
PROC SORT Statement Order SAS data set observations by the values of one or more character or numeric variables Ex. 1, Ex. 3, Ex. 4
BY Statement Specify the sorting variables Ex. 1, Ex. 2, Ex. 4
KEY Statement Specify sorting keys and variables