%let name=nc_tornado_animation; filename odsout '.'; %include '../democd57/tornado_history_data.sas'; data my_data; set all_data (where=(st='NC')); year=.; year=put(date,year4.); run; proc sort data=my_data out=my_data; by year; run; data anno_tornadoes; set my_data; length function color $8; xsys='2'; ysys='2'; hsys='3'; when='a'; color='red'; /* Note: In 2008, and prior, some tornadoes only have the start location */ /* If the end-point is unknown (zero) just draw a point at the start location */ if (elat=0 and elon=0) and (slat^=0 and slon^=0) then do; lat=slat; long=slon; function='label'; text='?'; hsys='3'; size=2.5; output; end; /* If you have a non-zero end-point, then draw a line from start to end */ else if (slat^=. and slon^=. and elat^=. and elon^=.) and (slat^=0 and slon^=0 and elat^=0 and elon^=0) then do; lat=slat; long=slon; function='move'; output; lat=elat; long=elon; function='draw'; hsys='4'; size=1; output; end; run; data my_map; set mapsgfk.us_counties (where=(density<=3 and statecode='NC')); run; proc gproject data=my_map out=my_map latlong eastlong degrees dupok parmout=work.projparm; id state county; run; /* Project the tornado coordinates with the same projparm as the map, so they line up correctly. */ proc gproject data=anno_tornadoes out=anno_tornadoes latlong eastlong degrees dupok parmin=work.projparm parmentry=my_map; id; run; /* annotate state outline on the county map */ proc gremove data=my_map out=anno_outline; by statecode notsorted; id county; run; data anno_outline; set anno_outline; length function $8; by statecode notsorted segment; xsys='2'; ysys='2'; hsys='3'; when='a'; color="gray88"; size=1.0; if first.segment or (lag(x)=. and lag(y)=.) then function='poly'; else function='polycont'; if x^=. and y^=. then output; run; proc sql noprint; select min(year) into :minyear separated by ' ' from my_data; select max(year) into :maxyear separated by ' ' from my_data; quit; run; /* create a data= data set for drawing the map */ data county_data; set mapsgfk.us_counties_attr (where=(statecode='NC')); length my_html $300; do year=&minyear to &maxyear by 1; /* only output mouseover text for 1 year, to reduce size of html file */ if year=&maxyear then my_html='title='||quote(trim(left(idname))); output; end; run; proc sort data=county_data out=county_data; by year; run; goptions border; goptions xpixels=1000 ypixels=500; options dev=sasprtc printerpath=gif animduration=1.2 animloop=0 animoverlay=no animate=start center; ODS LISTING CLOSE; ODS HTML path=odsout body="&name..htm" (title="NC Tornado Animation by Year") style=htmlblue; goptions gunit=pct htitle=6.0 htext=2.8 ftitle="albany amt/bold" ftext="albany amt"; goptions ctext=gray33; goptions cback=cxF5FFFA; pattern1 v=s c=white; options nobyline; title1 link="http://www.spc.noaa.gov/wcm/#data" ls=3.0 height=30pt "North Carolina Tornadoes"; proc gmap data=county_data map=my_map all anno=anno_outline; by year; id state county; note move=(13,16) c=red h=60pt font='albany amt/bold' "#byval(year)"; note c=gray55 move=(4,5) h=12pt "'?' represents tornadoes that have no documented path"; note c=gray55 move=(78,5) h=12pt link="http://www.spc.noaa.gov/wcm/#data" "Data through Sept 9, 2018"; choro state / levels=1 nolegend coutline=graye5 cdefault=white anno=anno_tornadoes html=my_html des='' name="&name"; run; quit; ODS HTML CLOSE; ODS LISTING;