Data visualization with SAS programming

gchart: controlling hbar order

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

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

Posted in reply to RobertAllison_SAS
hbar's "ascending" worked well.
Posts: 975

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:

proc sort data=goals;by rate;run;

proc sgplot data=goals;
yaxis discreteorder=data;
hbar bu / response=rate;
Regular Contributor
Posts: 238

Re: gchart: controlling hbar order

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

Ask a Question
Discussion stats
  • 4 replies
  • 4 in conversation