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;
CFC_SAS_Communities_400x225.jpg
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.