Data visualization with SAS programming

gchart: controlling hbar order

Reply
Regular Contributor
Posts: 199

gchart: controlling hbar order

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
SAS Employee
Posts: 977

Re: gchart: controlling hbar order

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).
Regular Contributor
Posts: 199

Re: gchart: controlling hbar order

hbar's "ascending" worked well.
Thanks.
SAS Super FREQ
Posts: 925

Re: gchart: controlling hbar order

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]
Regular Contributor
Posts: 230

Re: gchart: controlling hbar order

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

Ask a Question
Discussion stats
  • 4 replies
  • 2013 views
  • 0 likes
  • 4 in conversation