And if you do NOT mind a NOTE in the log stating "NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECTclause."
data have;
input var $;
cards;
1
2
A
Sr
R
Y
7
;
proc sql;
create table want as
select *
from have
order by monotonic() desc;
quit;
data have;
input var $;
cards;
1
2
A
Sr
R
Y
7
;
proc sql;
create table want(drop=rn) as
select *,monotonic() as rn
from have
order by rn desc;
quit;
And if you do NOT mind a NOTE in the log stating "NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECTclause."
data have;
input var $;
cards;
1
2
A
Sr
R
Y
7
;
proc sql;
create table want as
select *
from have
order by monotonic() desc;
quit;
If your table is not very big.
data have;
input var $;
cards;
1
2
A
Sr
R
Y
7
;
data want;
do i=nobs to 1 by -1;
set have nobs=nobs point=i;
output;
end;
stop;
drop i;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.