🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 07-31-2019 01:23 PM
(1781 views)
If I have created an animation and it is working, how do I add the date for each image so it changes as the animation is performed? I am using BASE sas. Is there a way to do this in the code used for animating?
options papersize=('11 in', '7 in')
printerpath=gif
animation=start
animduration=0.7
animloop=yes
noanimoverlay
nodate;
ods printer file='C:/Users/lindsey/Documents/Gifs/all-appearance.gif';
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
10 REPLIES 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Where do you want the date? On the graph in a corner, in the footnote/title, at the end of the line if a time series?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Preferably as a footnote!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So you'll need to figure out a way to get that date, from your data -usually a macro variable and then include it in a footnote statement. If you show the rest of the code I can likely help with figuring out the date variable part.
You can include that before your SGMAP or SGPLOT statements.
footnote "Date: &myDate.";
You can include that before your SGMAP or SGPLOT statements.
footnote "Date: &myDate.";
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This is my code. Thanks for all of your help!
PROC IMPORT OUT=seven DATAFILE="C:/Users/lindsey/Documents/try7.csv" DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
guessingrows=all;
RUN;
proc IMPORT out=full_week DATAFILE="C:/Users/lindsey/Documents/full_week.csv" DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
guessingrows=all;
RUN;
%macro mapAnnually(dsn=, start=, end=);
%let start=%sysfunc(inputn(&start,date9.));
%let end=%sysfunc(inputn(&end,date9.));
%let dif=%sysfunc(intck(day,&start,&end));
%do i=0 %to &dif;
%let date=%sysfunc(intnx(day,&start,&i,b));
proc sgmap
plotdata=&dsn noautolegend;
openstreetmap;
title 'flu outbreaks' x=Longitude y=Latitude/ markerattrs=(size=7 color=CX003399
symbol=circlefilled) transparency=0.32;
run;
%end;
%mend mapAnnually;
ods html close;
/*--Create animation--*/
options papersize=('11 in', '7 in')
printerpath=gif
animation=start
animduration=0.7
animloop=yes
noanimoverlay
nodate;
ods printer file='C:/Users/lindsey/Documents/Gifs/NEW.gif';
ods graphics / width=10in height=6in imagefmt=GIF;
%mapAnnually(dsn=seven, start=01Jan2019, end = 07Jan2019);
options printerpath=gif animation=stop;
ods printer close;
ods html;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You have no WHERE or filter in SG proc, so how does the picture change?
Anyways, looks like there already is a macro variable so you can use that directly.
footnote "Date: &date.";
Anyways, looks like there already is a macro variable so you can use that directly.
footnote "Date: &date.";
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Whoops must have deleted it when I copied it over! So this worked, but the date is written as "21550" and then "21551.." any idea why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
formats.
footnote "Date: %sysfunc(putn(&date, worddate.)";
footnote "Date: %sysfunc(putn(&date, worddate.)";
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I did this and the code barely ran and only gave me this note:
NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Quotes are messed up somewhere then most likely 😞 I can't see code or error so no idea.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
After restarting SAS, it worked! Thanks