But can I use SGMAP to animate a graph if it does not support the by statement?
How would you change the boundaries?
Thanks!
The best way to control the boundaries, in this case, is to overlay a CHOROMAP over the OpenStreetMap, without a response variable in the CHOROMAP. statement. Use a WHERE on the MAPDATA so that only the areas showing the flu data are drawn. This should give you consistency in what OSM tiles are used.
Giving credit where credit's due, @GraphGuy used this trick in his blog post about the recent California earthquakes.
Hope this helps!
Dan
Yes I did see your example. It did not run on my SAS and I had to terminate it. When attempting to use that code with my data, it runs but there is no output file.
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
NOTE: ODS statements in the SAS Studio environment may disable some output
features.
73
74 %macro mapAnnually(dsn=, start=, end=);
75 %let start=%sysfunc(inputn(&start,date9.));
76 %let end=%sysfunc(inputn(&end,date9.));
77 %let dif=%sysfunc(intck(day,&start,&end));
78 %do i=0 %to &dif;
79 %let date=%sysfunc(intnx(day,&start,&i,b));
80
81
82 proc sgmap
83
84 plotdata=&dsn;
85 where date_processed <= &date.;
86 openstreetmap;
87
88 scatter x=LONGitude y=LATitude/ markerattrs=(size=5
88 ! symbol=circlefilled);
89 run;
90
91
92 %end;
93 %mend mapAnnually;
94
95 ods html close;
96 /*--Create animation--*/
97 options papersize=('11 in', '7 in')
98 printerpath=gif
99 animation=start
100 animduration=0.1
101 animloop=yes
102 noanimoverlay
103 nodate;
104 ods printer
104 ! file='C:/Users/lindsey/documents/gifs/demoMap.gif';
NOTE: Writing ODS PRINTER output to DISK destination
"C:\Users\lindsey\documents\gifs\demoMap.gif", printer "gif".
105
106 ods graphics / width=10in height=6in imagefmt=GIF;
107
108 %mapAnnually(dsn=full_week, start=01Jan2019, end = 07Jan2019);
NOTE: PROCEDURE SGMAP used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: PROCEDURE SGMAP used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds
NOTE: PROCEDURE SGMAP used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: PROCEDURE SGMAP used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
NOTE: PROCEDURE SGMAP used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: PROCEDURE SGMAP used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
NOTE: PROCEDURE SGMAP used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
109
110 options printerpath=gif animation=stop;
111 ods printer close;
NOTE: ODS PRINTER printed no output.
(This sometimes results from failing to place a RUN statement before
the ODS PRINTER CLOSE statement.)
112 ods html;
NOTE: Writing HTML Body file: sashtml6.htm
113
114 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
126
I got it to work! Not sure why it was not working earlier. If my date is entered as "01Jan19:00:00:00" could that be why this method is not working with my data?
%let start=%sysfunc(inputn(&start,date9.));
76 %let end=%sysfunc(inputn(&end,date9.));
77 %let dif=%sysfunc(intck(day,&start,&end));
78 %do i=0 %to &dif;
79 %let date=%sysfunc(intnx(day,&start,&i,b));
I have narrowed it down to this part of the code being what I need to change to work the datetime column I have. I have been trying to play around with it but cannot seem to pinpoint what exactly needs to be altered. This is my first time working with code like thi.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.