%let name=insur; filename odsout '.'; /* SAS Imitation/enhancement of ... http://www.jdpa.com/pdf/2003073.pdf */ data mydata; input satisfaction name $ 5-50; colorvar=1; datalines; 884 Amica Mutual 834 Auto Club of So. Cal. 823 Erie Insurance Group 814 State Farm 807 Nationwide 806 California State Auto Assn. 806 GEICO 801 21st Century 797 Auto Club Group 789 The Hartford 778 American Family 778 Liberty Mutual 777 Allstate 770 Encompass 765 SAFECO 757 MetLife 756 Prudential 751 Travelers 742 Farmers 738 Other* 727 AIG 725 Progressive 706 OneBeacon ; run; proc sql; create table avg as select unique 'Industry Average' as name, 3 as colorvar, /* Hardcoded to get the exact value in jd power plot */ 777 as satisfaction /* round(avg(satisfaction)) as satisfaction */ from mydata; select satisfaction into :avg_satis from avg; quit; run; data mydata; set mydata avg; run; proc sort data=mydata out=mydata; by descending satisfaction; run; data space; input satisfaction name $ 5-50; colorvar=2; datalines; 0 ; run; data usaa; input satisfaction name $ 5-50; colorvar=2; datalines; 909 USAA ; run; data mydata; set mydata space usaa; barnum=_n_; run; data mydata; set mydata; length myhtml $200; myhtml= 'title='||quote( trim(left(name))||': '||trim(left(satisfaction))|| ' ')||' '|| 'href="http://www.google.com/search?hl=en&q='||trim(left(name))||'+insurance"'; /* 'href="insur.htm"'; */ run; /* This version is just like the original */ data anno_labels; set mydata; length function $8 text $75 color $12; when='a'; hsys='3'; color='black'; function='label'; size=.; style='"arial/bo"'; function='move'; xsys='2'; ysys='2'; midpoint=barnum; x=500; output; ysys='9'; y=.2; output; /* ever-so-slight offset to position bar labels a little higher */ function='cntl2txt'; output; function='label'; position='4'; text=trim(left(name))||'a0'x; output; function='move'; xsys='2'; ysys='2'; midpoint=barnum; x=satisfaction; output; ysys='9'; y=.2; output; function='cntl2txt'; output; function='label'; position='6'; text=' '||trim(left(satisfaction)); output; run; /* This is my special (hopefully improved) version, with labels inside the bars */ data anno_labels2; set mydata; length function $8 text $75 color $12; when='a'; hsys='3'; color='black'; function='label'; size=.; style='"arial/bo"'; function='move'; xsys='2'; ysys='2'; midpoint=barnum; x=500; output; ysys='9'; y=.2; output; /* ever-so-slight offset to position bar labels a little higher */ function='cntl2txt'; output; function='label'; position='4'; text=trim(left(name))||'a0'x; output; function='move'; xsys='2'; ysys='2'; midpoint=barnum; x=satisfaction; output; ysys='9'; y=.2; output; function='cntl2txt'; output; function='label'; position='4'; text=trim(left(satisfaction))||'a0'x; if name eq trim(left('Industry Average')) then color='white'; output; run; data anno_axis; length function $8 text $75 color $12; when='a'; hsys='3'; color='black'; size=.001; /* Annotate dashed line between usaa and others */ xsys='2'; ysys='2'; line=2; function='move'; x=500; midpoint=25; output; function='draw'; x=1000; midpoint=25; output; /* Annotate solid line at top, for axis */ xsys='2'; ysys='1'; line=1; function='move'; x=500; y=100; output; function='draw'; x=1000; y=100; output; /* odd, if I reverse the order of 2 following codeblocks, both lines are at bottom */ style='"arial/bo"'; /* Annotate tickmarks & labels along top axis */ xsys='2'; ysys='1'; function='move'; x=500; y=100; output; function='draw'; size=.001; color='black'; ysys='9'; y=.7; output; function='cntl2txt'; output; function='label'; size=.; color='gray77'; position='b'; text='500'; output; xsys='2'; ysys='1'; function='move'; x=600; y=100; output; function='draw'; size=.001; color='black'; ysys='9'; y=.7; output; function='cntl2txt'; output; function='label'; size=.; color='gray77'; position='b'; text='600'; output; xsys='2'; ysys='1'; function='move'; x=700; y=100; output; function='draw'; size=.001; color='black'; ysys='9'; y=.7; output; function='cntl2txt'; output; function='label'; size=.; color='gray77'; position='b'; text='700'; output; xsys='2'; ysys='1'; function='move'; x=800; y=100; output; function='draw'; size=.001; color='black'; ysys='9'; y=.7; output; function='cntl2txt'; output; function='label'; size=.; color='gray77'; position='b'; text='800'; output; xsys='2'; ysys='1'; function='move'; x=900; y=100; output; function='draw'; size=.001; color='black'; ysys='9'; y=.7; output; function='cntl2txt'; output; function='label'; size=.; color='gray77'; position='b'; text='900'; output; xsys='2'; ysys='1'; function='move'; x=1000; y=100; output; function='draw'; size=.001; color='black'; ysys='9'; y=.7; output; function='cntl2txt'; output; function='label'; size=.; color='gray77'; position='b'; text='1000'; output; run; GOPTIONS DEVICE=gif; goptions xpixels=725 ypixels=800; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Insurance Company Satisfaction") style=minimal; goptions noborder; goptions gunit=pct htitle=2.7 htext=1.7 ftitle="arial/bold" ftext="arial/bold"; axis1 label=none value=(justify=right) value=none offset=(1.8,1.8); /* make this axis along bottom of plot 'invisible' */ axis2 label=none minor=none order=(500 to 1000 by 100) major=none minor=none value=none color=white; title1 h=3 font="arial/bo" "J.D. Power and Associates"; title2 h=3 font="arial/bo" "2003 National Auto Insurance Study"; title3 h=2.5 font="arial/bo" ls=1.5 "Overall Satisfaction"; title4 h=1.5 " "; title5 a=90 h=25pct " "; title6 a=-90 h=5pct " "; pattern1 v=s color=cx7EC0EE; pattern2 v=s color=graydd; pattern3 v=s color=cxff0000; proc gchart data=mydata anno=anno_labels2; hbar barnum / discrete type=sum sumvar=satisfaction nostats noframe maxis=axis1 raxis=axis2 subgroup=colorvar coutline=black nolegend space=.4 anno=anno_axis ref=&avg_satis lref=1 cref=cxff0000 clipref html=myhtml des="" name="&name"; run; pattern1 v=s color=cx7EC0EE; pattern2 v=s color=graydd; pattern3 v=s color=gray33; proc gchart data=mydata anno=anno_labels; hbar barnum / discrete type=sum sumvar=satisfaction nostats noframe maxis=axis1 raxis=axis2 subgroup=colorvar coutline=black nolegend space=.4 anno=anno_axis html=myhtml des="" name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;