You can use the SORTVALIDATE
system option to specify whether the SORT procedure validates that
a data set is sorted correctly when the data set sort indicator shows
a user-specified sort order. The user can specify a sort order by
using the SORTEDBY= data set option in a DATA statement or by using
the SORTEDBY= option in the DATASETS procedure MODIFY statement. When
the sort indicator is set by a user, SAS cannot be absolutely certain
that a data set is sorted according to the variables in the BY statement.
If the SORTVALIDATE
system option is set and the data set sort indicator was set by a
user, the SORT procedure performs a sequence check on each observation
to ensure that the data set is sorted according to the variables in
the BY statement. If the data set is not sorted correctly, SAS sorts
the data set.
At the end of a successful
sequence check or at the end of a sort, the SORT procedure sets the
Validated sort information to Yes. If a sort is performed,
the SORT procedure updates the
Sortedby
sort information to the variables that are specified in the BY statement.
If an output data set
is specified, the
Validated sort information
in the output data set is set to Yes. If no sort is necessary, the
data set is copied to the output data set.