BookmarkSubscribeRSS Feed
gzr2mz39
Quartz | Level 8
How do I maintain the order the variable bu is displayed in my data (ie goals)?

proc sort data=goals;by rate;run;

axis3 label=("Count") value=(h=2);
proc gchart data=goals anno=cbackanno;
hbar bu /
discrete
sumvar=rate
4 REPLIES 4
GraphGuy
Meteorite | Level 14
I assume you're wanting the bars to be in the same order as your "proc sort" produced? (and assuming that your data has 1 obsn per each "bu" ... ie, not having gchart summarize several obsns per each "bu")...

If so, then you can use hbar's "ascending" (or descending) option to control the bar order.

If you wanted the bars to be in some other order (not ascending/descending based on the bar height values), then you would need to get a little trickier, and create a variable that has values of the desired order, and then use a user-defined-format such that that order value will 'print' as the desired "bu" value. (but sounds like you won't need to go to this extra level of complexity).
gzr2mz39
Quartz | Level 8
hbar's "ascending" worked well.
Thanks.
DanH_sas
SAS Super FREQ
If you are using SAS 9.2, you have another alternative. You can use the the SGPLOT procedure to create data-order bar charts:

[pre]
proc sort data=goals;by rate;run;

proc sgplot data=goals;
yaxis discreteorder=data;
hbar bu / response=rate;
run;
[/pre]
Filipvdr
Pyrite | Level 9

thanks DanH, i was looking for your answer a long time

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 4380 views
  • 0 likes
  • 4 in conversation