BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lindseyn
Obsidian | Level 7

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
Reeza
Super User
formats.

footnote "Date: %sysfunc(putn(&date, worddate.)";

View solution in original post

10 REPLIES 10
Reeza
Super User
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?
lindseyn
Obsidian | Level 7

Preferably as a footnote!

Reeza
Super User
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.";
lindseyn
Obsidian | Level 7

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;
Reeza
Super User
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.";
lindseyn
Obsidian | Level 7

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?

Reeza
Super User
formats.

footnote "Date: %sysfunc(putn(&date, worddate.)";
lindseyn
Obsidian | Level 7

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.
Reeza
Super User
Quotes are messed up somewhere then most likely 😞 I can't see code or error so no idea.
lindseyn
Obsidian | Level 7

After restarting SAS, it worked! Thanks Smiley Happy

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 2007 views
  • 0 likes
  • 2 in conversation