%let name=salmonella_map; filename odsout '.'; /* http://www.cdc.gov/salmonella/typhimurium-live-poultry-04-13/map.html */ data my_data; input statecode $ 1-2 cases; datalines; WA 19 MT 2 ND 5 MN 3 WI 6 OR 12 ID 3 WY 4 SD 9 NE 14 IA 7 MO 18 KS 16 CO 37 UT 11 NV 1 CA 9 AZ 8 NM 19 TX 32 OK 15 LA 9 MS 6 AL 1 GA 4 FL 5 SC 1 TN 2 IL 1 IN 10 KY 4 WV 1 VA 1 NY 17 VT 1 NH 1 MA 2 ; run; proc format; value buckfmt 1='1-7' 2='8-15' 3='16+' ; run; data my_data; set my_data; format bucket buckfmt.; if cases=0 then bucket=.; else if cases<=7 then bucket=1; else if cases<=15 then bucket=2; else if cases>=16 then bucket=3; else bucket=.; run; data my_data; set my_data (where=(bucket in (1 2 3))); length html $300; html= 'title='||quote( trim(left(fipnamel(stfips(statecode))))||'0d'x|| trim(left(cases))||' cases')|| ' href="salmonella_map_info.htm"'; run; /* Label the map, using some Tech Support code: */ data maplabel; set mapsgfk.uscenter; original_order=_n_; run; proc sql; create table maplabel as select maplabel.*, my_data.cases, my_data.bucket, my_data.html from maplabel left join my_data on maplabel.statecode=my_data.statecode; quit; run; proc sort data=maplabel out=maplabel; by original_order; run; data maplabel; set maplabel; length function $8 color $8; retain flag 0; xsys='2'; ysys='2'; hsys='3'; when='a'; function='label'; style="albany amt/bold"; position='5'; size=2.0; if bucket=3 then color='white'; else if bucket=. then color='graycc'; else color='black'; if ocean^='Y' and flag^=1 then do; position='2'; text=trim(left(statecode)); output; position='5'; text=translate(trim(left(cases)),' ','.'); output; end; else if ocean='Y' then do; position='6'; text=translate(trim(left(statecode))||' '||trim(left(cases)),' ','.'); output; function='move'; output; flag=1; end; else if flag=1 then do; function='draw'; size=.25; output; flag=0; end; run; data my_us; set mapsgfk.us; run; goptions device=png; goptions border; goptions xpixels=900 ypixels=600; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Salmonella case map") style=htmlblue; goptions gunit=pct htitle=4 htext=2.5 ftitle="albany amt/bold" ftext="albany amt/bold"; goptions ctext=gray33; pattern1 v=s c=cxccff9a; pattern2 v=s c=cx92d14f; pattern3 v=s c=cx517c23; legend1 label=(position=top 'Cases') shape=bar(.15in,.15in) value=(j=center) order=descending position=(bottom right) mode=share across=1 offset=(-8,15); title1 j=l move=(+3,+0) h=3.3 ls=1.5 "August 19, 2013"; title2 j=l move=(+3,+0) h=3.3 "Persons infected with the outbreak strain of " c=red font="albany amt/italic" "Salmonella Typhimurium,"; title3 j=l move=(+3,+0) h=3.3 "by State"; title4 a=-90 h=2pct ' '; proc gmap data=my_data map=my_us all; id statecode; choro bucket / discrete midpoints=1 2 3 cdefault=white legend=legend1 coutline=gray9d anno=maplabel html=html des='' name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;