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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: