Hi Guys
i want reverse order in sashelp.class
| Name |
| John |
| Jeffrey |
| Janet |
| Jane |
| James |
| Henry |
| Carol |
| Barbara |
| Alice |
| Alfred |
| Joyce |
| Judy |
| Louise |
| Mary |
| Philip |
| Robert |
| Ronald |
| Thomas |
| William |
Hi,
try like this:
data want;
do point = 10 to 1 by -1, 11 to nobs;
set sashelp.class nobs=nobs point=point;
output;
end;
stop;
run;
or like this:
data want2;
do point = 10 to 1 by -1;
set sashelp.class nobs=nobs point=point;
output;
end;
do until(eof);
set sashelp.class(firstobs=11) end=eof;
output;
end;
stop;
run;
or (like @Kurt_Bremser suggested) like this:
data want3;
do point = 10 to 1 by -1;
set sashelp.class nobs=nobs point=point;
output;
end;
stop;
run;
proc append base = want3 data = sashelp.class(firstobs=11);
run;
Mind that it is a reversed order of observations and not a reversed sort by name.
All the best
Bart
I can see no order here; please explain the rule for getting this sequence.
Sort the first 10 observations (OBS=10) in DESCENDING order to your want dataset, then append the rest (FIRSTOBS=11).
Hi,
try like this:
data want;
do point = 10 to 1 by -1, 11 to nobs;
set sashelp.class nobs=nobs point=point;
output;
end;
stop;
run;
or like this:
data want2;
do point = 10 to 1 by -1;
set sashelp.class nobs=nobs point=point;
output;
end;
do until(eof);
set sashelp.class(firstobs=11) end=eof;
output;
end;
stop;
run;
or (like @Kurt_Bremser suggested) like this:
data want3;
do point = 10 to 1 by -1;
set sashelp.class nobs=nobs point=point;
output;
end;
stop;
run;
proc append base = want3 data = sashelp.class(firstobs=11);
run;
Mind that it is a reversed order of observations and not a reversed sort by name.
All the best
Bart
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.