Sorting Data in SAS with Proc Sort

Posted by bkloss | SAS | Sunday 18 January 2009 7:54 pm

The SAS Sort Procedure

Sorting data in SAS is an everyday task accomplished for a variety of reasons.

    1. Certain types of reports require that data be presorted to present results accurately.
    2. Programs that include a where statement can execute more quickly on a sorted data set.
    3. Unlike SQL, SAS requires data sets to be sorted by a common variable before a join operation can occur.

      These examples are just a few situations where a presorted data set is necessary or essential.  Luckily, PROC SORT is a relatively simple procedure.  The Basic Syntax is below:

      Proc Sort data =<data set>;

      By <variable-1 … variable-n>;

      Run ;