BookmarkSubscribeRSS Feed
kcskaiser
Fluorite | Level 6

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.

1 REPLY 1
GraphGuy
Meteorite | Level 14

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

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1638 views
  • 0 likes
  • 2 in conversation