BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Reeza
Super User
You may need to control the boundaries for SGMAP to work with an animation. It seems to zoom automatically, that causes most of the issue.
lindseyn
Obsidian | Level 7

But can I use SGMAP to animate a graph if it does not support the by statement?

 

How would you change the boundaries?

 

Thanks!

Reeza
Super User
Did you review the example I've posted mulitple times? Did it not run? Does it have a BY statement? You don't need a BY statement and since you likely want to have the old values present I don't think you need a BY statement either.

I don't know how to control the SGMAP boundaries and not seeing one in the documentation. I suspect you can kludge it - but you likely have to add some fake data with the four corner points of the map is my guess, which is definitely annoying.
DanH_sas
SAS Super FREQ

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

lindseyn
Obsidian | Level 7

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        
Reeza
Super User
There are no image files generated at all? What is the gpath set to?

ods listing gpath = '/folders/myfolders/';

What version of SAS are you using? It works in 9.4M5 and M6 - I tested it.
lindseyn
Obsidian | Level 7

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? 

Reeza
Super User
That's a datetime, not a date, which means that other portions of the code may have needed to change and would definitely affect your code. But that shouldn't have affected the example code I was using if you ran it exactly as posted.
lindseyn
Obsidian | Level 7
  %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.

Reeza
Super User
Can you change your datetimes to dates? That would be :

new_var_date = datepart(datetime_variable);

Then the code above should work. Or you can change the increment to DTDAY instead of day. You need to do one of these, not both.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 25 replies
  • 1628 views
  • 3 likes
  • 5 in conversation