BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BrahmanandaRao
Lapis Lazuli | Level 10

 

 

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
1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Amethyst | Level 16

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

4 REPLIES 4
BrahmanandaRao
Lapis Lazuli | Level 10
in class dataset first 10 obs should be in reverse order remaing same
yabwon
Amethyst | Level 16

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1453 views
  • 0 likes
  • 3 in conversation