%let name=mc1c; filename odsout '.'; %let mc1path=\\l72586.na.sas.com\public\VAST_2011\MC_1_Materials_3-30-2011\; libname mydata "&mc1path"; /* Find microblog postings with certain keywords (later, plot them on the map) */ data matches; set mydata.microblogs; flag=1; if index(text,' flu ')^=0 then do; output; end; else if index(text,' fever')^=0 then do; output; end; else if index(text,' chill')^=0 then do; output; end; else if index(text,' sweat')^=0 then do; output; end; else if index(text,' ache')^=0 then do; output; end; else if index(text,' pain')^=0 then do; output; end; else if index(text,' fatigue')^=0 then do; output; end; else if index(text,' cough')^=0 then do; output; end; else if index(text,' breathing')^=0 then do; output; end; else if index(text,' nausea')^=0 then do; output; end; else if index(text,' vomit')^=0 then do; output; end; else if index(text,' diarrhea')^=0 then do; output; end; run; /* Map for Mini-Challenge 1 http://hcil.cs.umd.edu/localphp/hcil/vast11/index.php/taskdesc/index */ %let map_bw=&mc1path.Vastopolis_Map.gif; /* Coordinates from the map in the MC1_Dataset_README.docx file */ /* bottom/left corner */ %let bottom_long=-93.5673; %let bottom_lat=42.1609; /* top/right corner */ %let top_long=-93.1923; %let top_lat=42.3017; data anno_image; length function $8 style $20 imgpath $200; xsys='2'; ysys='2'; hsys='3'; when='b'; flag=2; function='move'; x=&bottom_long; y=&bottom_lat; output; function='image'; x=&top_long; y=&top_lat; imgpath="&map_bw"; style='fit'; output; run; /* a fake map area, to guarantee the extents of the map are covered */ /* (only needed when image area is bigger than map area) */ data my_map; map_id=0; x=&bottom_long; y=&bottom_lat; output; x=&top_long; y=&bottom_lat; output; x=&top_long; y=&top_lat; output; x=&bottom_long; y=&top_lat; output; run; data combined; set my_map anno_image matches; run; proc gproject data=combined out=combined dupok eastlong degrees; id map_id; run; data my_map anno_image matches; set combined; if flag=1 then output matches; else if flag=2 then output anno_image; else output my_map; run; /* turn matches into an annotate dataset of markers on the map */ data matches; set matches; length text color $20; xsys='2'; ysys='2'; when='a'; function='label'; style='albany amt/unicode'; text='25cb'x; size=1; /* color='Aff000055'; */ /* drat! - gifanim doesn't support transparent colors */ color='cxff0000'; run; data anno_weather; set mydata.weather; length function $8 color $20 text $20; xsys='3'; ysys='3'; position='5'; when='a'; hsys='3'; x=50; y=50; function='label'; size=20; style="marker"; text='F'; /* direction arrow (pointing to right, for angle=0) */ color='a007FFF55'; /* transparent blue */ /* angle was calculated previously, to go along with wind direction */ run; %macro do_map(date); data temp_matches; set matches (where=(date<="&date"d)) anno_weather (where=(date="&date"d)); run; title3 "through &date"; proc gmap map=my_map data=my_map anno=temp_matches; id map_id; choro map_id / levels=1 nolegend coutline=graydd anno=anno_image; run; %mend; /** Create the HTML file that will display the **/ /** GIF animation. **/ data _null_; file "&name..htm"; put ''; put '
'; put '
'; put ''; put ''; filename gifname "&name..gif"; /* Set the GOPTIONs necessary for the animation */ goption reset device=gifanim gsfname=gifname gsfmode=replace /* For the first graph, gsfmode=replace */ disposal=background /* none, background, previous, or unspecified */ userinput /* allow user input during animation, if supported by browser */ delay=70 /* .70 seconds between images */ iteration=0 /* loop through animation 1 time (0=infinite) */ ; goptions noborder; goptions cback=white; goptions gunit=pct htitle=16pt htext=11pt ftitle="arial/bold" ftext="arial"; pattern v=e color=gray99; goptions xpixels=1100 ypixels=700; title1 ls=1.5 "Location of microblogs containing 'flu-like' keywords..."; title2 "(flu, fever, chill, sweat, ache, pain, fatigue, cough, breathing, nausea, vomit, diarrhea)"; footnote1 j=l c=cx007FFF font="albany amt/bold" "Blue Arrow = wind direction"; %do_map(30apr2011); /* for all subsequent graphs, append them to the gif animation */ goptions gsfmode=append; %do_map(01may2011); %do_map(02may2011); %do_map(03may2011); %do_map(04may2011); %do_map(05may2011); %do_map(06may2011); %do_map(07may2011); %do_map(08may2011); %do_map(09may2011); %do_map(10may2011); %do_map(11may2011); %do_map(12may2011); %do_map(13may2011); %do_map(14may2011); %do_map(15may2011); %do_map(16may2011); %do_map(17may2011); %do_map(18may2011); %do_map(19may2011); %do_map(20may2011); /* Now, write out the end of the animatd gif trailer - otherwise it won't play in some gif players. Internet Explorer will sometimes display animated GIFs that do not have it, but the W3C spec says it is required. Office 2002 and 2003 apparently do not recognize the files unless they include this trailer. */ data _null_; file gifname recfm=n mod; put '3B'x; run; quit;