Here's a way to do it with Gchart ...
data my_data; length category $20 subgroup $10 sam $20 colorvar $20; infile datalines dlm=','; input category subgroup amount sam; colorvar=trim(left(subgroup))||'_'||trim(left(category)); datalines; All sites,AIR,500,n=2812(100%) All sites,AMR,400,n=1044(100%) Female breast,AIR,50,n=554(20%) Female breast,AMR,5,n=89(9%) Male prostate,AIR,110.0,n=332(12%) Male prostate,AMR,10,n=74(7%) Lung & bronchus,AIR,40,n=242(9%) Lung & bronchus,AMR,35,n=186(18%) Colon & rectum,AIR,45,n=231(8%) Colon & rectum,AMR,70,n=102(10%) ; run;
proc format; picture posval low-high='000,009'; run;
data my_data; set my_data; if subgroup='AIR' then amount=-amount; run;
data anlabels; set my_data; length text $100; xsys='2'; ysys='2'; hsys='3'; when='a'; yc=category; x=amount; function='label'; size=2.5; text=strip(""||strip(left(put(amount,posval.)))||left(sam)); if subgroup='AMR' then do; text='a0'x||trim(left(text)); position='>'; end; if subgroup='AIR' then do; text=trim(left(text))||'a0'x; position='<'; end; if category='All sites' and subgroup='AMR' then do; text=trim(left(text))||'a0'x; position='<'; end; if category='All sites' and subgroup='AIR' then do; text='a0'x||trim(left(text)); position='>'; end; run;
goptions device=png;
goptions gunit=pct htitle=18pt ftitle="albany amt/bold" htext=12pt ftext="albany amt/bold"; goptions ctext=gray33;
axis1 label=none value=(height=11pt font="Albany AMT/bold" justify=right) style=0 offset=(9,10);
axis2 label=none value=(height=11pt font="Albany AMT/bold") minor=none major=none /*width=3*/;
legend1 label=none shape=bar(.15in,.15in) across=2 colmajor;
/* solid colors for the AIR bars */ pattern1 v=solid color=cxfc0018; pattern2 v=solid color=cx2f4c72; pattern3 v=solid color=cxec81ec; pattern4 v=solid color=cx808080; pattern5 v=solid color=cx4f7fbd; /* transparent colors for the AMR bars */ pattern6 v=solid color=Afc001888; pattern7 v=solid color=A2f4c7288; pattern8 v=solid color=Aec81ec88; pattern9 v=solid color=A80808088; pattern10 v=solid color=A4f7fbd88;
title1; footnote;
proc gchart data=my_data; format amount posval.; note font="Albany AMT/bold" h=12pt move=(22pct,87pct) 'AIR' move=(90pct,87pct) 'AMR'; hbar category / sumvar=amount nostat maxis=axis1 raxis=axis2 width=6 space=1.5 coutline=gray77 annotate=anlabels subgroup=colorvar nolegend /* legend=legend1 */; run;
... View more