Incorrect results might occur when you use a SAS® data set that resulted from running the SORT procedure against a DBMS table


Incorrect results might occur when you use a SAS data set that was the result of using the SORT procedure against a database management system (DBMS) table. The SORT procedure updates the header of the resulting SAS data set that has been sorted and verified. The incorrect results occur when the collating sequence that the DBMS uses to sort the data is different than the one used by SAS, and subsequent code uses the header information to generate results.

The sort information provided by the sort indicator is used internally for performance improvements. The following are several ways that the sort indicator might be used:

Here are some examples of cases in which the sort indicator might be incorrectly set:

To work around this issue, have SAS do the sorting.  This can be accomplished by setting the SORTPGM system option or doing a PROC SORT on the resulting data set after the data has been read into SAS.