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

I created an animated barchart using proc sgplot.  The barchart animates over a period of minutes.  I am trying to add in a text box or footnote that shows the current time as the animation progresses.  I was able to animate the time, but the animation of the graph disappeared.  

 

Below is the code I use to animate the barchart.  I have also attached a sample of the dataset that I use.  The dataset am is only the am portion of the attached dataset.  The dataset myattrmap is imported from another file which details the colors of the bars by group.

 


%macro lineAnnuallyAM(dsn=, start=, end=);
%let start = "6:00 AM"t;
%let end = "9:30 AM"t;

%let dif = %sysfunc(intck(minute,&start,&end));
%do i=0 %to &dif;
%let time=%sysfunc(intnx(minute,&start,&i,b),timeampm9.);

proc sgplot data=am dattrmap = myattrmap;
*used to control the time period shown on the graph;
where &start < time < "&time"t;

title j=center font = 'Times New Roman' color = white bcolor = '#085156' 'Bethlehem Central School District Deployment Model AM - Vehicles in Operation Carrying Students';
vbar time /response = buses stat = sum group = School_Group datalabel attrid=myid;
xaxis display =(nolabel) valuesrotate=vertical values = ("6:00"t to "09:30"t by "0:05"t);
yaxis grid values = (0 to 85 by 5);

refline "7:35 AM" /
axis = x lineattrs=(pattern=2 thickness = 3 color = "#FF0000") label = "7:35 AM";

refline "8:00 AM" /
axis = x lineattrs=(pattern=2 thickness = 3 color = "#0000FF") label = "8:00 AM";

refline "9:20 AM" /
axis = x lineattrs=(pattern=2 thickness = 3 color = "#00FF00") label = "9:20 AM";

run;

quit;
%end;
%mend lineAnnuallyAM;

 

/*--Create animation--*/
options papersize=('11 in', '7 in')
printerpath=gif
animation=start
animduration=0.25
animloop=no
noanimoverlay
nonumber;
ods printer file='C:\Users\Kristi Titler\OneDrive - Student Transportation Inc\Desktop\AM Deployment.gif';

ods graphics / width=10in height=6in imagefmt=GIF;

%lineAnnuallyAM(dsn=am , start="6:00 AM"t, end="09:30 AM"t);

options printerpath=gif animation=stop;
ods printer close;

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Would adding the following line after your TITLE statement work for you?

 

title2 "Time = &time";

 

Hope this helps!
Dan

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ

If you use the BY statement in PROC SGPLOT to create the animation, then the BY-group variable will appear automatically.

 

ktitler
Calcite | Level 5

The issue I have with that is that I want the graph to build over time until the entire graph is filled. Using the by variable to create the gif only shows the bar at that specific time.   The macro I have creates the graph from the starting time to the current time.

DanH_sas
SAS Super FREQ

Would adding the following line after your TITLE statement work for you?

 

title2 "Time = &time";

 

Hope this helps!
Dan

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 3 replies
  • 680 views
  • 0 likes
  • 3 in conversation