%let name=life_expectancy; /* Set your current-working-directory (to read/write files), if you need to ... %let rc=%sysfunc(dlgcdir('c:\someplace\public_html')); */ filename odsout '.'; /* WHO data from 2015 (snapshot from Wikipedia Jan 31, 2019) https://en.wikipedia.org/wiki/List_of_countries_by_life_expectancy rank both female_rank female male_rank male * * Japan 1 83.7 1 86.8 6 80.5 China 53 76.1 80 77.6 44 74.6 UK 20 81.2 27 83.0 16 79.4 US 31 79.3 33 81.6 32 76.9 Singapore 3 83.1 2 86.1 10 80.0 South Korea 11 82.3 3 85.5 20 78.8 Philippines 124 68.5 117 72.0 126 65.3 */ data my_data; length sex $10; input life_expectancy sex $6-6 country $ 7-80; if sex='M' then sex='Male'; if sex='F' then sex='Female'; life_expectancy_formatted=trim(left(put(life_expectancy,comma5.0))); datalines; 74.6 M China 77.6 F China 80.5 M Japan 86.8 F Japan 79.4 M United Kingdom 83.0 F United Kingdom 76.9 M United States 81.6 F United States 80.0 M Singapore 86.1 F Singapore 78.8 M South Korea 85.5 F South Korea 65.3 M Philippines 72.0 F Philippines ; run; data my_data; set my_data; length tip_info $300; tip_info='a0'x||'0d'x|| trim(left(country))||'0d'x|| trim(left(sex))||' life expectancy = '||trim(left(life_expectancy)); run; ods escapechar='^'; data my_anno; set my_data; layer="front"; function="text"; textsize=14; anchor='center'; x1space='datavalue'; xc1=country; y1space='datapercent'; y1=5; textfont="arial"; discreteoffset= .15; textcolor="cxffa500"; label="^{unicode '2642'x}"; output; /* male */ discreteoffset=-.12; textcolor="cx008000"; label="^{unicode '2640'x}"; output; /* female */ run; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Life Expectancy") style=htmlblue; ods graphics / imagefmt=png imagename="&name" width=864px height=504px border imagemap; title1 color=gray33 ls=0.5 h=18pt "Life Expectancy of Selected Nations (2015)"; proc sgplot data=my_data noborder pad=(right=20pct left=15pct) sganno=my_anno; styleattrs datacolors=(cx33c977 cxffe173) backcolor=cxCCCC99 wallcolor=cxCCCC99; vbarparm category=country response=life_expectancy / group=sex groupdisplay=cluster clusterwidth=.55 name='bars' datalabel=life_expectancy_formatted datalabelattrs=(size=11pt color=gray77) tip=(tip_info) tiplabel=('Details') dataskin=gloss; xaxis discreteorder=data display=(nolabel) Fitpolicy=SplitAlways Splitchar=' ' display=(noticks) valueattrs=(size=11pt weight=bold color=gray33); yaxis label='Age' labelposition=top values=(0 to 100 by 20) display=(noticks noline) grid gridattrs=(color=gray55 pattern=dot) offsetmin=0 offsetmax=0 valueattrs=(size=11pt weight=normal color=gray33) labelattrs=(size=11pt weight=bold color=gray33); keylegend 'bars' / position=topright location=inside noborder across=1 outerpad=(right=15px top=5px) fillheight=15; run; quit; ODS HTML CLOSE; ODS LISTING;