Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Arranging GCHART value in Descending order

Accepted Solution Solved
Reply
Regular Contributor
Posts: 215
Accepted Solution

Arranging GCHART value in Descending order

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;


Accepted Solutions
Solution
‎07-14-2015 04:09 PM
Regular Contributor
Posts: 215

Re: Arranging GCHART value in Descending order

Thanks Miguel, that's very helpful.

View solution in original post


All Replies
Super Contributor
Posts: 336

Re: Arranging GCHART value in Descending order

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

Regular Contributor
Posts: 215

Re: Arranging GCHART value in Descending order

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,

Super User
Posts: 10,538

Re: Arranging GCHART value in Descending order

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;

Super Contributor
Posts: 336

Re: Arranging GCHART value in Descending order

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!

Solution
‎07-14-2015 04:09 PM
Regular Contributor
Posts: 215

Re: Arranging GCHART value in Descending order

Thanks Miguel, that's very helpful.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 496 views
  • 4 likes
  • 3 in conversation