BookmarkSubscribeRSS Feed
Jeema
Calcite | Level 5

I would like to create a dynamic chart where the graph is refreshed in between short time intervals of say 5 seconds with different events plotted on the chart.

I have created a macro that creates a separate dataset for each event and within the macro have provided the plot graph function. So for each iteration(i.e each event) there will be a graph created.
Below is the described code I have created in Base SAS.But I am getting say 7 graphs for 7 events on the same page,wherein I want only a single graph to refresh every 5 seconds with the latest iterated event.
Any help for the code change below will be appreciated.


proc sql noprint;
   select count(distinct Event)
      into :n
      from Utildem.CbemaLabel;
   select distinct Event
      into :Event1 - :Event%left(&n)
      from Utildem.CbemaLabel;
quit;

%macro makeds;
   %do i=1 %to &n;
      data &&Event&i (drop=Event);
         set work.cbema;
 
         if Event="&&Event&i";
 
  proc gplot data=&&Event&i ;
plot magnitude*duration / annotate = annocbema haxis = axis1 vaxis = axis2 html=tips1;
plot2 magnitude*incident /
haxis = axis1 vaxis = axis2 html=tips1/*noframe*/
autovref cvref=graydd
autohref chref=graydd
des="" name="&name" ;

run;

/*      run;*/
slept= sleep(5);
   %end;
%mend makeds;
%makeds;

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

Sorry, I am not following your question: " I want only a single graph to refresh every 5 seconds with the latest iterated event".  Graphs are output, there is no 'refresh', you would need to run the program again.  Maybe you want to output each graph to a separate file, e.g. graph_output_time_0, graph_output_time_5, ...?

GraphGuy
Meteorite | Level 14

I'm not sure I understand exactly what you're wanting, but here are a couple of possibilities:

If you know all the 7 events ahead of time, I guess you could create a gif animation, with 5 second delay between each frame. There are several examples of animated gif graphs on this page:

    Robert Allison's SAS/Graph Samples

Alternatively, if the data you're wanting to plot is happening 'live' (ie, you don't have all the data ahead of time), and you're wanting a graph to 'refresh' itself every 5 seconds, you could possibly do that with SAS/Intrnet. With SAS/Intrnet, it generates the graph on-the-fly when you go to the url. The graph can be set up to read the latest/greatest data whenever it is run.

I have one SAS/Intrnet example that queries the time, and draws a representation of a clock every time it's run. I set it up to refresh itself every 5 seconds using the following code after my proc gchart (this is just a portion - not the entire sas/intrnet job) ...

proc gchart data=a;

pie category / sumvar=seconds clockwise noheading

coutline=blue slice=none des='';

run;

/*

See the following webpage for info about 'refresh' ...

http://webdesign.about.com/cs/metatags/a/aa080300a.htm

*/

%let refresh=5;

data _null_;

file _webout;

put "<meta http-equiv='refresh' content='&refresh'>";

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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