<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to Create an Animated BarChart through time using SGPlot Procedure in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-Create-an-Animated-BarChart-through-time-using-SGPlot/m-p/554490#M9515</link>
    <description>&lt;P&gt;You can do this by creating a short macro and using a WHERE statement to control the time shown on the graph. Here's a fully worked example that you can use to see how this is done and then you can modify your code accordingly. Note that you need SAS 9.4 + to have this work. HTH.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*--This program requires SAS 9.4--*/

%macro lineAnnually(dsn=, start=, end=);
   %let start=%sysfunc(inputn(&amp;amp;start,anydtdte9.));
   %let end=%sysfunc(inputn(&amp;amp;end,anydtdte9.));
   %let dif=%sysfunc(intck(month,&amp;amp;start,&amp;amp;end));
     %do i=0 %to &amp;amp;dif;
      %let date=%sysfunc(intnx(month,&amp;amp;start,&amp;amp;i,b),date9.);

         proc sgplot data=sashelp.stocks; 
             
            &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;*used to control the time period shown on the graph;
             where date &amp;gt; &amp;amp;start and date &amp;lt; "&amp;amp;date"d and stock='IBM';&lt;/STRONG&gt; &lt;/FONT&gt;
            
             series x=date y=open; 
             xaxis interval=month min='01Jan1990'd max='01Jan2007'd; 
             yaxis values=(0 to 200 by 50); 
             footnote j=l 'Created using the SGPLOT Procedure, using SAS UE'; 
         run; 

        quit;
    %end;
%mend lineAnnually;



/*--Create animation--*/
options papersize=('11 in', '7 in') 
printerpath=gif 
animation=start 
animduration=0.1 
animloop=yes 
noanimoverlay
nodate;
ods printer file='/folders/myfolders/LineGraph.gif';

ods graphics / width=10in height=6in imagefmt=GIF;

%lineAnnually(dsn=sashelp.stocks , start=01Jan1990, end=01Jan2007);

options printerpath=gif animation=stop;
ods printer close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 27 Apr 2019 16:46:08 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-04-27T16:46:08Z</dc:date>
    <item>
      <title>How to Create an Animated BarChart through time using SGPlot Procedure</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Create-an-Animated-BarChart-through-time-using-SGPlot/m-p/554384#M9492</link>
      <description>&lt;P&gt;I am trying to animate a stacked barchart over time.&amp;nbsp; As time passes I want the graph to populate on the screen. I want the gif to start with the empty graph and then as time passes fill in the chart horizontally.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code to create the stacked barcharts.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import datafile = "C:\Users\...\Desktop\model.xlsx"&lt;BR /&gt;dbms = xlsx&lt;BR /&gt;out = model&lt;BR /&gt;REPLACE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data am;&lt;BR /&gt;set model;&lt;BR /&gt;if time &amp;gt; "12:00"t then delete;&lt;BR /&gt;format time timeampm9.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data pm;&lt;BR /&gt;set model;&lt;BR /&gt;if time &amp;lt;= "12:00"t then delete;&lt;BR /&gt;format time timeampm9.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data myattrmap;&lt;BR /&gt;length linecolor $ 9 fillcolor $ 9;&lt;BR /&gt;input ID $ value $ linecolor $ fillcolor $;&lt;BR /&gt;datalines;&lt;BR /&gt;myid OX yellow yellow&lt;BR /&gt;myid SS orange orange&lt;BR /&gt;myid WS purple purple&lt;BR /&gt;myid ES green green&lt;BR /&gt;myid HS lightblue lightblue&lt;BR /&gt;myid IS blue blue&lt;BR /&gt;myid JH red red&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data = am dattrmap = myattrmap;&lt;BR /&gt;title 'Deployment Model AM';&lt;BR /&gt;vbar time /response = buses stat = sum group = Group datalabel seglabel attrid=myid;&lt;BR /&gt;xaxis display =(nolabel) valuesrotate=vertical values = ("6:15"t to "09:00"t by "0:05"t);&lt;BR /&gt;yaxis grid values = (0 to 40 by 5);&lt;BR /&gt;refline "7:30 AM" /&lt;BR /&gt;axis = x lineattrs=(pattern=2 thickness = 2 color = green) label = "7:30 AM";&lt;BR /&gt;refline "7:50 AM" /&lt;BR /&gt;axis = x lineattrs=(pattern=2 thickness = 2 color = red) label = "7:50 AM";&lt;BR /&gt;refline "8:20 AM" /&lt;BR /&gt;axis = x lineattrs=(pattern=2 thickness = 2 color = lightblue) label = "8:20 AM";&lt;BR /&gt;refline "8:50 AM" /&lt;BR /&gt;axis = x lineattrs=(pattern=2 thickness = 2 color = blue) label = "8:50 AM";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sgplot data = pm dattrmap = myattrmap;&lt;BR /&gt;title 'Deployment Model PM';&lt;BR /&gt;vbar time /response = buses stat = sum group = Group datalabel seglabel attrid=myid;&lt;BR /&gt;xaxis display =(nolabel) valuesrotate=vertical values = ("14:00"t to "16:50:00"t by "0:05"t);&lt;BR /&gt;yaxis grid values = (0 to 40 by 5);&lt;BR /&gt;refline "2:20 PM" /&lt;BR /&gt;axis = x lineattrs=(pattern=2 thickness = 2 color = green) label = "2:20 PM";&lt;BR /&gt;refline "2:50 PM" /&lt;BR /&gt;axis = x lineattrs=(pattern=2 thickness = 2 color = red) label = "2:50 PM";&lt;BR /&gt;refline "3:20 PM" /&lt;BR /&gt;axis = x lineattrs=(pattern=2 thickness = 2 color = lightblue) label = "3:20 PM";&lt;BR /&gt;refline "3:50 PM" /&lt;BR /&gt;axis = x lineattrs=(pattern=2 thickness = 2 color = blue) label = "3:50 PM";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 19:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Create-an-Animated-BarChart-through-time-using-SGPlot/m-p/554384#M9492</guid>
      <dc:creator>ktitler</dc:creator>
      <dc:date>2019-04-26T19:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to Create an Animated BarChart through time using SGPlot Procedure</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Create-an-Animated-BarChart-through-time-using-SGPlot/m-p/554490#M9515</link>
      <description>&lt;P&gt;You can do this by creating a short macro and using a WHERE statement to control the time shown on the graph. Here's a fully worked example that you can use to see how this is done and then you can modify your code accordingly. Note that you need SAS 9.4 + to have this work. HTH.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*--This program requires SAS 9.4--*/

%macro lineAnnually(dsn=, start=, end=);
   %let start=%sysfunc(inputn(&amp;amp;start,anydtdte9.));
   %let end=%sysfunc(inputn(&amp;amp;end,anydtdte9.));
   %let dif=%sysfunc(intck(month,&amp;amp;start,&amp;amp;end));
     %do i=0 %to &amp;amp;dif;
      %let date=%sysfunc(intnx(month,&amp;amp;start,&amp;amp;i,b),date9.);

         proc sgplot data=sashelp.stocks; 
             
            &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;*used to control the time period shown on the graph;
             where date &amp;gt; &amp;amp;start and date &amp;lt; "&amp;amp;date"d and stock='IBM';&lt;/STRONG&gt; &lt;/FONT&gt;
            
             series x=date y=open; 
             xaxis interval=month min='01Jan1990'd max='01Jan2007'd; 
             yaxis values=(0 to 200 by 50); 
             footnote j=l 'Created using the SGPLOT Procedure, using SAS UE'; 
         run; 

        quit;
    %end;
%mend lineAnnually;



/*--Create animation--*/
options papersize=('11 in', '7 in') 
printerpath=gif 
animation=start 
animduration=0.1 
animloop=yes 
noanimoverlay
nodate;
ods printer file='/folders/myfolders/LineGraph.gif';

ods graphics / width=10in height=6in imagefmt=GIF;

%lineAnnually(dsn=sashelp.stocks , start=01Jan1990, end=01Jan2007);

options printerpath=gif animation=stop;
ods printer close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 27 Apr 2019 16:46:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Create-an-Animated-BarChart-through-time-using-SGPlot/m-p/554490#M9515</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-27T16:46:08Z</dc:date>
    </item>
  </channel>
</rss>

