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.
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;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.