Some DBMSs, including Oracle, place NULL values at the end of a sorted list. SAS normally places NULL values at the beginning of a sorted list. In SAS, to use BY-group processing, SAS expects that values for a BY group are already sorted before it performs BY-group processing. If SAS determines that values are not sorted, then BY-group processing stops. Therefore, if NULL values are not at the beginning of a sorted list, SAS determines that the values are not sorted correctly.
If you use PROC SQL with an ORDER BY statement to sort your data, then the SQL code is generated so that NULL values are placed at the beginning of the sorted list. In this way, SAS can perform any BY-group processing without stopping.
For more information, see Potential Result Set Differences When Processing Null Data and Sorting DBMS Data.