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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4984 views
  • 0 likes
  • 4 in conversation