Much appreciation for the tip. The unfortunate angle though is that the PRESORTED option seems to work even when the metadata is inaccurate. An example: * Create dummy data for test purposes;
* Disclaimer: all values are fake;
data test;
length patid encounterid 4.;
infile datalines;
input patid encounterid;
datalines;
12345 876543
24256 987654
14233 263547
42987 763853
;
run;
* sort the data;
proc sort data = test;
by patid encounterid;
run;
* test the sortedby metadata values;
proc sql noprint;
select name, sortedby
into :names separated by " "
, :sortedby separated by " "
from dictionary.columns
where lowcase(libname) = "work" and
lowcase(memname) = "test";
quit;
%put &names &sortedby;
* Create a new data set from the original;
data test2;
set test;
run;
* Now look at the metadata again;
proc sql noprint;
select name, sortedby
into :names separated by " "
, :sortedby separated by " "
from dictionary.columns
where lowcase(libname) = "work" and
lowcase(memname) = "test2";
quit;
%put &names &sortedby;
* Look at the log output using the presorted option though;
proc sort data = test2 presorted;
by patid encounterid;
run; The caveat is that one can sort a data set, but if one used that sorted data to make another data set (in the example, I literally did nothing to test), the sortedby metadata values for the resulting table don't carry over and are reset to 0. Unfortunately (or fortunately, because it DOES keep my job interesting) in this distributed database environment in which I work, I don't have a say in (or even knowledge of) the code the remote locations use to create the data sets my QA program evaluates.
... View more