Data visualization with SAS programming

Annotating HBAR SubGroups in the bar and at the end

Reply
Contributor
Posts: 25

Annotating HBAR SubGroups in the bar and at the end

I have  an HBAR GCHART that is currently annoted with count values centered inside the bar which is subgrouped by month. Kind of like this example.Each bar is a day of the week... each subdivision a month.

==========================================================================================

|         400    |        900                    |                      3000                                                       |            500                    |

==========================================================================================

 

To do this I created a middle data set and calculated the center and values for each of the amounts. What I would like to do now is add the total to the end of the bar, outside the bar.   |  4800   for example.

But I can't figure out how to do this. My current program (without data) is attached.

SAS Employee
Posts: 967

Re: Annotating HBAR SubGroups in the bar and at the end

I've created a short example using sashelp.class to demonstrate one way to annotate values at the ends of the Hbars ...

 


data anno_in_bar; set sashelp.class;
xsys='2'; ysys='2'; when='a';
midpoint=sex; subgroup=name;
function='label'; position='4'; text=trim(left(name));
run;

 

proc sql;
create table anno_end_bar as
select unique sex, sum(height) as total_height
from sashelp.class
group by sex;
quit; run;

data anno_end_bar; set anno_end_bar;
xsys='2'; ysys='2'; when='a';
midpoint=sex; x=total_height;
function='label'; position='6'; text='20'x||'Total='||trim(left(total_height));
run;

 

data anno_all;
length text $50;
set anno_in_bar anno_end_bar;
run;

 

pattern1 v=s color=yellow repeat=50;
proc gchart data=sashelp.class anno=anno_all;
hbar sex / type=sum sumvar=height nostats subgroup=name nolegend;
run;

 


foo.png
Ask a Question
Discussion stats
  • 1 reply
  • 360 views
  • 0 likes
  • 2 in conversation