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.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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