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
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.