%let name=swine_flu; filename odsout '.'; %let mult=2.5; proc format; value legn_fmt 1='Aseguran estar libres de contagios' 2='Reportaron decesos en las últimas 24 horas' 3='Con brotes de influenza; algunos registran fallecimientos (*)' ; run; data fludata; format colornum legn_fmt.; input num1 num2 colornum /* x/y offsets for the 2 points of the line, and then the text label */ x1 y1 x2 y2 x3 y3 idname $ 32-80; datalines; 25 1 2 4 3 1 0 1 1 Baja California Norte 0 0 1 . . . . . . Baja California Sur 0 0 1 . . . . . . Sonora 0 0 1 . . . . . . Sinaloa 28 0 3 . . . . 0 0 Chihuahua 0 0 1 . . . . . . Coahuila 7 1 2 0 5 0 0 0 3 Nuevo Leon 3 1 2 0 4 1 0 1 1 Tamaulipas 76 10 2 2 0 7 4 1 1 San Luis Potosi 0 0 1 . . . . . . Zacatecas 0 0 1 . . . . . . Durango 0 0 1 . . . . . . Nayarit 30 0 3 . . . . 0 0 Jalisco 0 0 1 . . . . . . Colima 0 0 1 . . . . . . Michoacan 0 0 1 . . . . . . Guerrero 2 2 2 -7 0 . . -1 1 Aguascalientes 1 2 2 -4 -4 -3 0 -1 1 Guanajuato 5 0 3 -5 -5 . . 0 0 Queretaro 24 0 3 0 0 3 0 1 1 Veracruz 11 0 3 2 4 3 0 1 1 Hidalgo 44 3 3 -5 -5 . . 0 0 Mexico 73 18 2 1 -1 2 -6 0 0 Distrito Federal 35 0 3 1.5 3 3 0 1 1 Tlaxcala 0 0 1 . . . . . . Puebla 17 0 3 -2 -4 . . 0 0 Morelos 8 3 2 3 -3 0 0 0 0 Oaxaca 0 0 1 . . . . . . Tabasco 0 0 1 . . . . . . Chiapas 0 0 1 . . . . . . Campeche 0 0 1 . . . . . . Yucatan 0 0 1 . . . . . . Quintana Roo ; run; proc sql; create table fludata as select fludata.*, mexico2.id from fludata left join maps.mexico2 on fludata.idname eq mexico2.idname; quit; run; data fludata; set fludata; length htmlvar $500; htmlvar='title='||quote( trim(left(idname))||'0d'x|| 'Influenza: '|| trim(left(num1))||'0d'x|| 'Decesos: '|| trim(left(num2)) ) ||' '|| 'href="http://theswine.files.wordpress.com/2009/04/picture-11.png"'; run; data target_anno; length function $8; xsys='3'; ysys='3'; hsys='3'; when='b'; x=50; y=50; function='pie'; style='pempty'; color='grayed'; width=3; rotate=360; do size=4 to 49 by 3; output; end; run; /* Now, create a 'centers' dataset with the estimated centers. */ %annomac; %centroid( maps.mexico, labels, id ); proc sql; create table labels as select labels.*, fludata.* from labels left join fludata on labels.id=fludata.id; quit; run; data labels; set labels (where=(colornum^=1)); length function color $8 style $20; xsys='2'; ysys='2'; hsys='3'; when='a'; function='move'; output; if (x1 ^= .) then do; function='pie'; size=.15; rotate=360; style='psolid'; output; xsys='9'; ysys='9'; function='draw'; x=x1*&mult; y=y1*&mult; output; function='draw'; x=x2*&mult; y=y2*&mult; output; end; function="cntl2txt"; output; function='label'; position='5'; size=.; style=''; xsys='9'; ysys='9'; x=x3*&mult; y=y3*&mult; text=trim(left(idname)); output; function="cntl2txt"; output; function='label'; position='5'; size=.; style=''; xsys='9'; ysys='9'; x=x3*&mult; y=(y3*&mult)-1*&mult; text=trim(left(num1)); style='"arial/bold"'; output; if num2 ^= 0 then do; function="cntl2txt"; output; function='label'; position='5'; size=.; style=''; xsys='9'; ysys='9'; x=x3*&mult; y=(y3*&mult)-2*&mult; text='('||trim(left(num2))||'*)'; style=''; output; end; run; %let spacing=2.6; data info; length function $8 text $50 style $20; xsys='3'; ysys='3'; hsys='3'; position='6'; when='a'; x=92; y=59.0; function='move'; output; x=x+6; y=y+6; function='image'; imgpath='flu_phone.jpg'; style='fit'; output; x=64; y=65; function='move'; output; x=x+34; y=y+23; function='bar'; color='white'; style='solid'; line=0; output; x=64; y=65; function='move'; output; x=x+34; y=y+23; function='bar'; color='red'; style='empty'; line=0; output; x=64; y=71.0; function='move'; output; x=x+34; function='draw'; color='gray'; line=33; size=.1; output; x=65; function='label'; style='"arial/bold"'; color=''; size=.; y=86; text="Si pienso que tengo"; output; y=y-&spacing; text="influenza, ¿qué debo hacer?"; output; style='"arial"'; y=y-&spacing; text="Buscar atención médica en"; output; y=y-&spacing; text="forma inmediata. Para reporte"; output; y=y-&spacing; text="de casos, comunicarse al"; output; y=y-&spacing; text="teléfono"; output; y=y-&spacing-.5; text="Locatel:"; output; x=74.5; style='"arial/bold"'; y=72.8; text="01 800 123 10 10"; output; x=73.5; y=y-&spacing-.5; text="56 58 11 11"; output; y=y-&spacing; text="55 33 55 33"; output; run; data labels; set labels info; run; /* Create an annotated 'shadow' to go behind the map. It's ok to use the already-projected map for this. */ data anno_shadow; set maps.mexico; orig_order+1; run; proc sort data=anno_shadow out=anno_shadow; by id segment orig_order; run; proc gremove data=anno_shadow out=anno_shadow; by id; id id; run; data anno_shadow; length COLOR FUNCTION $8; retain FX FY FUNCTION; set anno_shadow; by id segment; xsys='2'; ysys='2'; color='cxa3a7a6'; size=1.75; when='B'; style='msolid'; if first.segment then do; FUNCTION = 'poly'; FX = X; FY = Y; end; else if FUNCTION ^= ' ' then do; if X = . then do; X = FX; Y = FY; output; FUNCTION = ' '; end; else FUNCTION = 'polycont'; end; if FUNCTION ^= ' ' then do; output; if last.segment then do; X = FX; Y = FY; output; end; end; run; /* Give a little x & y offset, so it will look like a shadow */ data anno_shadow; set anno_shadow; /* x=x+.0004; y=y-.0006; */ x=x-8; y=y-10; run; data anno_back; set target_anno anno_shadow; run; /* Define a template, to get the graphic above the map ... */ ods path work.template(update) sashelp.tmplmst; proc template; define style styles.banner; parent = styles.minimal; /* Put the graphic above the title */ style Body from Document / prehtml = "
" ; end; run; goptions device=png; goptions xpixels=570 ypixels=570; goptions noborder; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="Swine Flu in Mexico (SAS/Graph gmap)") style=banner; goptions gunit=pct htitle=5.00 ftitle="arial/bold" htext=2.2 ftext="arial"; legend1 label=none position=(bottom left) mode=share across=1 shape=bar(.15in,.15in) offset=(1,-12); pattern1 v=s c=cxf5efdb; pattern2 v=s c=cxf00016; pattern3 v=s c=cxfe9200; title1 j=l " SURGEN MÁS CASOS"; title2 j=l " Nuevo León declaró alerta, luego de que confirmó el caso de una mujer procedente"; title3 j=l " del Distrito Federal que murió por influenza porcina. En la capital se registraron"; title4 j=l " 5 decesos más. Hay alerta en Veracruz y Baja California"; footnote1 h=10.2pct " "; proc gmap map=maps.mexico data=fludata all anno=labels; id id; choro colornum / discrete coutline=cxa3a7a6 legend=legend1 html=htmlvar anno=anno_back des="" name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;