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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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