PROC SQL sorts nulls, or missing values, before character
or numeric data. Therefore, when you specify ascending order, missing
values appear first in the query results.
The following example
sorts the rows in the CONTINENTS table by the LowPoint column:
libname sql 'SAS-library';
proc sql;
title 'Continents, Sorted by Low Point';
select Name, LowPoint
from sql.continents
order by LowPoint;
Because three continents
have a missing value in the LowPoint column, those continents appear
first in the output. Note that because the query does not specify
a secondary sort, rows that have the same value in the LowPoint column,
such as the first three rows of output, are not displayed in any particular
order. In general, if you do not explicitly specify a sort order,
then PROC SQL output is not guaranteed to be in any particular order.
Sorting Columns That Contain Missing Values