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;
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";
options papersize=('11 in', '7 in')
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;
If you use the BY statement in PROC SGPLOT to create the animation, then the BY-group variable will appear automatically.
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.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.