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

Hi All,

Can anyone tell me how to arrange the following gchart value (mean in the Y axis) in descending order? Thanks.

proc gchart data=Have;  

vbar Name / discrete type=mean      

                 inside=mean width=20                                                                                               

                sumvar=Height mean;

run;                                                                                                                                   

quit;

1 ACCEPTED SOLUTION

Accepted Solutions
mlogan
Lapis Lazuli | Level 10

Thanks Miguel, that's very helpful.

View solution in original post

5 REPLIES 5
M_Maldonado
Barite | Level 11

it depends on the your values.

for example:

axis1 order=(50 to 10 by -5);

google "sas axis descending order" and you will see doc and papers with examples.

link to one of those here SAS/GRAPH(R) 9.2: Axis statement

I hope it helps,

-Miguel

mlogan
Lapis Lazuli | Level 10

Hi Miguel,

I google it but don;t understand much from there. What I wanted my vertical bars to show up in descending order. Let's say my highest mean is 12 and lowest is 1, what would be the code for it can you please write it for me?

proc gchart data=Have;

vbar Name / discrete type=mean 

                inside=mean width=20                                                                                           

                sumvar=Height mean;

run;                                                                                                                               

quit;

Untitled.png

Thanks,

ballardw
Super User

For best control with Gchart it is often easiest to presummarize the data, sort as needed and then chart the result.

proc summary data = have nway;

class name;

var height;

output out = want mean=;

run;

proc sort data=want; by descending height; run;

proc gchart data=want;

vbar Name / discrete type=mean 

                inside=mean width=20                                                                                           

                sumvar=Height mean;

run;                                                                                                                               

quit;

M_Maldonado
Barite | Level 11

I googled a bit more to find a paper with an example of what we are looking for. Cool thing about SAS is all info is out there.

It turns out this proc supports an option for descending. Just add it after the slash "/". An example below.

proc gchart data=sashelp.baseball;

vbar
team /
discrete type=mean 

                 inside=mean width=20

                sumvar=nhits mean descending;

run;

quit;

Good luck!

mlogan
Lapis Lazuli | Level 10

Thanks Miguel, that's very helpful.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 4600 views
  • 6 likes
  • 3 in conversation