%let name=plague_world_map; filename odsout '.'; /* colors for bubbles & countries/land */ %let c1=cxffffb2; %let c2=cxfecc5c; %let c3=cxfd8d3c; %let c4=cxe31a1c; %let cout=gray44; %let colback=cxeeeee4; /* Data from: http://www.humanosphere.org/global-health/2013/09/the-plague-yes-that-plague-still-exists/ */ data my_data; input cases y_position country $ 12-80; datalines; 10581 83.0 Congo 7182 69.0 Madagascar 1309 59.5 Zambia 972 53.5 Uganda 600 48.0 Mozambique 230 44.0 Tanzania 227 40.0 China 185 36.0 Peru 170 32.0 Malawi 100 28.0 Indonesia 57 24.0 United States 43 20.0 Viet Nam ; run; /* Calculate the quartile (I don't like it starting at zero, so I add one) */ /* proc rank data=my_data out=my_data groups=4 ties=low; var cases; ranks Quartile; run; data my_data; set my_data; color_bin=quartile+1; run; */ /* The quartile-binning didn't split the data along good natural break-points, so I'm doing it manually. */ data my_data; set my_data; if cases<=100 then color_bin=1; else if cases<=500 then color_bin=2; else if cases<=2000 then color_bin=3; else color_bin=4; run; data my_data; set my_data; length idname $55; /* this must match the length in the map dataset, to guarantee correctness */ idname=country; if country='Congo' then idname='Democratic Republic of Congo'; if country='Tanzania' then idname='Tanzania, United Republic of'; length my_html $300; my_html='title='||quote( trim(left(country))||'0d'x|| trim(left(put(cases,comma12.0)))||' cases of plague' ); run; data my_map; set mapsgfk.world (where=(density<=1 and idname^='Antarctica')); run; proc gproject data=my_map out=my_map latlong eastlong degrees project=robinson; id id; run; data anno_text; length function $8 color $12 style $35 text $300 html $300; xsys='3'; ysys='3'; hsys='3'; when='a'; /* background color for text at bottom of infographic */ x=0; y=0; function='move'; output; x=100; y=15.5; function='box'; color='cx09374e'; style='solid'; line=0; output; x=0; y=0; function='move'; output; x=100; y=15.5; function='box'; color="&colback"; style='empty'; line=0; output; /* Now, the text */ function='label'; position='6'; x=2.5; size=5.4; style='Franklin Gothic Demi Cond'; color='cx08394a'; y=96; text='DID YOU KNOW THE PLAGUE STILL EXISTS?'; output; color='cxb41d2c'; style='Franklin Gothic Demi'; size=3.9; y=83.5; text="21,725 human cases of plague"; output; style='Franklin Gothic Demi'; size=3.0; y=y-4; text='were reported worldwide'; output; size=2.5; style='Arial Narrow'; color='cx08394a'; y=87.5; text='In the first decade of the 21st century (2000-2009):'; output; y=34; text="The disease known as the 'Black Death' has killed millions since biblical"; output; y=y-3.0; text='times, yet it has been slowed in the past century by improvements in'; output; y=y-3.0; text='rodent-proof housing, urban hygiene, and clothing that protects against'; output; y=y-3.0; text='flea bites. Advances in scientific research have also played a significant'; output; y=y-3.0; text='role. Although the plague is not as pervasive as it once was, it still'; output; y=y-3.0; text='exists and kills.'; output; color="&colback"; y=13.0; text='Mapped data reflect countries in which more than 40 plague cases were reported, 2000-2009.'; output; y=y-3.0; text='Commissioned by the American Society of Tropical Medicine and Hygiene.'; output; y=y-3.0; text='Source: The American Journal of Tropical Medicine and Hygiene doi: 10.4269/ajtmh.13-0191 (2013).'; output; html='href='||quote('http://www.ajtmh.org/content/journals/10.4269/ajtmh.13-0191'); y=y-3.0; text='http://www.ajtmh.org/content/early/2013/09/12/atjmh.13.0191.full.pdf+html.'; output; html=''; run; /* add mouse-over text, containing the text */ data anno_text; set anno_text; length html $300; if html='' then html='title='||quote(trim(left(text))); run; %let max_area=150; /* maximum pie area */ proc sql noprint; select max(cases) into :max_val from my_data; quit; run; data anno_bubbles; set my_data; length function $8 color $12 style $35 text $300 html $300; xsys='3'; ysys='3'; hsys='3'; when='a'; html=my_html; y=y_position; x=72.0; function='move'; output; x=86.5; function='draw'; line=33; size=.001; output; function='label'; position='+'; size=2.5; style='Arial Narrow'; color='cx08394a'; cbox="&colback"; x=86.5; position='>'; text='a0a0'x||trim(left(country)); output; style='albany amt'; size=1.8; position='<'; text='a0'x||trim(left(put(cases,comma12.0))); output; x=72.0; function='pie'; rotate=360; position=''; if color_bin=1 then color="&c1"; if color_bin=2 then color="&c2"; if color_bin=3 then color="&c3"; if color_bin=4 then color="&c4"; size=.01+sqrt((cases/&max_val)*&max_area/3.14); style='psolid'; output; style='pempty'; color="&cout"; output; run; /* Ignore annotate errors, if you get any... (such as line=33) */ data ignore_error; function='seterror'; size=100000; output; run; data anno_all; set ignore_error anno_text anno_bubbles; run; goptions device=png; goptions border; ODS LISTING CLOSE; ODS html path=odsout body="&name..htm" (title="Plague World Map") style=htmlblue; goptions gunit=pct ftitle='albany amt/bold' ftext='albany amt' htitle=28pt htext=12pt; goptions ctext=gray33; goptions cback=&colback; goptions nodisplay; goptions xpixels=601 ypixels=604; proc gslide anno=anno_all des='' name='text'; run; pattern1 v=s c=&c1; pattern2 v=s c=&c2; pattern3 v=s c=&c3; pattern4 v=s c=&c4; goptions xpixels=451 ypixels=272; title1 h=2 ' '; title2 a=-90 h=1 ' '; footnote h=2 ' '; proc gmap data=my_data map=my_map (where=(x>-4000 and x<5000)) all; id idname; choro color_bin / discrete nolegend cdefault=white cempty=graydd coutline=&cout stretch html=my_html des='' name="map"; run; goptions display; goptions xpixels=601 ypixels=604; proc greplay nofs igout=work.gseg tc=tempcat; tdef map_pies des='star trek' 0/ llx=0 lly=0 ulx=0 uly=100 urx=100 ury=100 lrx=100 lry=0 1/ llx=0 lly=32 ulx=0 uly=77 urx=75 ury=77 lrx=75 lry=32 ; template map_pies; treplay 0:text 1:map des='' name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;