%let name=meningitis; filename odsout '.'; %let litegray=graybb; /* Imitation & enhancement of http://www.cdc.gov/hai/outbreaks/meningitis-facilities-map.html */ /* Get the locations of facilities that got the contaiminated steroid */ PROC IMPORT OUT=offices DATAFILE="meningitis.xls" DBMS=XLS REPLACE; RANGE="Sheet1$A3:D79"; GETNAMES=YES; RUN; data offices; set offices; length citydesc office_url $100.; city=propcase(city); run; /* Determine the lat/long of each city */ proc geocode data=offices out=offices (rename=(state=statecode)) lookup=sashelp.zipcode CITY; run; /* convert degrees to westlong radians (since our map is in radians) */ data offices; set offices; anno_flag=1; long=x; lat=y; run; /* Get the state abbreviations, and their lat/long locations */ data label_anno; set mapsgfk.uscenter (where=(statecode not in ('AK' 'HI' 'DC' 'PR'))); anno_flag=2; run; /* Get the map */ data state_map; set mapsgfk.us_states (where=(statecode not in ('AK' 'HI' 'PR') and (density < 3))); run; /* combine, project, and separate */ data combined; set state_map offices label_anno; run; proc gproject data=combined out=combined latlong eastlong degrees dupok; id statecode; run; data state_map offices label_anno; set combined; if anno_flag=1 then output offices; else if anno_flag=2 then output label_anno; else output state_map; run; /* Just get 1 obsn per city, but make the charttip have all the facility names */ proc sort data=offices out=office_anno; by statecode city; run; data office_anno; set office_anno; by statecode city; retain html; length html $1000; /* *** Here's the tricky bit! *** */ /* start the list of facilities */ if first.city then do; html= 'href='||quote('#'||trim(left(statecode)))|| ' title="'||trim(left(city))||', '||trim(left(statecode))||': '||'0d'x|| '------------------'; end; /* append to the list of facilities */ html=trim(left(html))||'0d'x||trim(left(facility)); /* terminate the list of facilities with a double-quote */ if last.city then do; html=trim(left(html))||'"'; output; end; run; /* Create a red dot, with link & chart-tip for each regional office */ data office_anno; set office_anno; length function color $8 text $20; xsys='2'; ysys='2'; hsys='3'; when='a'; function='pie'; rotate=360; size=0.8; style='psolid'; color='cxff0000'; output; /* make a dark ring around pie, to help distinguish overlapping ones */ style='pempty'; color='gray33'; line=1; html=''; output; run; /* Determine which states have target facilities, so you can color the state abbreviations accordingly. */ data label_anno; set label_anno; original_order=_n_; statecode=fipstate(state); run; proc sql; create table label_anno as select unique label_anno.*, offices.statecode as foofoo, offices.statecode as color_flag from label_anno left join offices on label_anno.statecode = offices.statecode; quit; run; proc sort data=label_anno out=label_anno; by original_order; run; /* Create an annotate dataset with the state abbreviations, to use to label each of the states. The tricky part is that you want some labels to be out over the ocean. */ /* this code modified from online help example */ data label_anno; length function color $8 style $20; xsys='2'; ysys='2'; hsys='3'; when='a'; retain flag 0; set label_anno; function='label'; style='albany amt/bold'; text=statecode; size=2.25; if color_flag^='' then color="gray33"; else color="&litegray"; position='5'; if ocean='Y' then do; position='6'; output; function='move'; flag=1; end; else if flag=1 then do; function='draw'; size=.25; flag=0; end; output; run; /* Combine some of the annotation datasets */ data all_anno; set label_anno office_anno; run; goptions device=png; goptions xpixels=1000 ypixels=700; goptions border; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="States receiving recalled Methylprednisolone Acetate (possible meningitis)") style=htmlblue; goptions gunit=pct ftitle="albany amt/bold" ftext="albany amt" htitle=5 htext=3.0; pattern1 v=s c=cxacc9ff repeat=100; title1 ls=1.5 link="http://www.cdc.gov/hai/outbreaks/meningitis-facilities-map.html" c=gray33 "Potential Meningitis Exposure Map"; title2 ls=1.0 link="http://www.cnn.com/2012/10/08/health/meningitis-q--a/?hpt=he_c1" c=gray55 "Facilities that received contaminated " c=gray33 " methylprednisolone acetate " c=gray55 " steroid"; proc gmap data=offices map=state_map all; id statecode; note move=(3,8) c=gray55 "Mouse-over and/or 'click' red dots"; note move=(3,5) c=gray55 "to see facility names."; choro statecode / statistic=freq cdefault=white coutline=gray66 anno=all_anno nolegend des='' name="&name"; run; /* Now, create the table */ title1 h=15pt " "; footnote; options pagesize=1000 nobyline; /* If you want to take out the pagebreak/lines between the tables */ * ods html options(pagebreak='no'); /* Set up the anchor tags, and the drilldown href for the facilities. */ data offices; set offices; phone=translate(trim(left(phone)),'-',' '); label state_anchor='State'; length state_anchor $200; state_anchor=""||trim(left(statecode))||""; label facility_link='Facility'; length facility_link $500; facility_link=""||trim(left(facility))||""; run; proc sort data=offices out=offices; by statecode city; run; proc report data=offices style(header)=[background=white foreground=gray33]; by statecode; column state_anchor city facility_link phone; define state_anchor / order; run; quit; ODS HTML CLOSE; ODS LISTING;