Hello @Mushy,
Alternatively you can create one or more replacement keys whose sort order reverses the sort order of the corresponding original keys. For example, use -sub for a numeric variable sub or
-input(put(sub,$hex6.),hex6.)
for a character variable sub of length 3. (For character variables of arbitrary lengths you could replace each character c by byte(255-rank(c)).)
Example using mkeintz's dataset CARS:
proc sql noprint;
select quote(trim(name)) into :varlist separated by ','
from dictionary.columns
where libname='WORK' & memname='CARS';
quit;
data _null_;
if _n_=1 then do;
dcl hash h(ordered:'a', multidata:'y');
h.definekey('make','_w');
h.definedata(&varlist);
h.definedone();
end;
set cars end=last;
_w=-weight;
h.add();
if last then h.output(dataset:'want');
run;
... View more