<?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: Increment months by macros do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522446#M141844</link>
    <description>&lt;P&gt;I have monthly observations&lt;/P&gt;</description>
    <pubDate>Wed, 19 Dec 2018 07:24:32 GMT</pubDate>
    <dc:creator>somebody</dc:creator>
    <dc:date>2018-12-19T07:24:32Z</dc:date>
    <item>
      <title>Increment months by macros do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522438#M141836</link>
      <description>&lt;P&gt;I am trying to write a macro that draw graph every month, thus it requires a DO loop with increment by month. How do I do that ?&amp;nbsp;My code are:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;%macro TS_animation(dataset=,start=, end=, incr=);
  %do month=&amp;amp;start %to &amp;amp;end %by &amp;amp;incr;
  	proc sgplot data= &amp;amp;dataset.;
		.......
	run;
  %end;
%mend TS_animation;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 06:14:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522438#M141836</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2018-12-19T06:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: Increment months by macros do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522439#M141837</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start=1;
%let end=12;
%let incr=1;&lt;BR /&gt;
/*create a month variable in the dataset you are passing and use the where to subset by do loop*/&lt;BR /&gt;
%macro TS_animation(dataset=,start=, end=, incr=);
  %do month=&amp;amp;start %to &amp;amp;end %by &amp;amp;incr;
  	proc sgplot data= &amp;amp;dataset.;
where month=&amp;amp;month;
		.......
	run;
  %end;
%mend TS_animation;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Dec 2018 06:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522439#M141837</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-12-19T06:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Increment months by macros do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522442#M141840</link>
      <description>&lt;P&gt;Thank you for your answer but I would like to input time (month) values for the start and end, for example, when I call the macro, it would be like this :&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%TS_anomation( dataset=sample, start = '01Jan2000'd, end='31Dec2010'd);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The way I understand you answer is that the month variable is in an integer.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 06:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522442#M141840</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2018-12-19T06:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Increment months by macros do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522443#M141841</link>
      <description>&lt;P&gt;Do you have a date or only the month in the dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can extract the month by using&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sysfunc(month(&amp;amp;start.))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 07:02:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522443#M141841</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-12-19T07:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Increment months by macros do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522444#M141842</link>
      <description>&lt;P&gt;Do you want to increment an INTEGER values like in your code?&lt;/P&gt;
&lt;P&gt;Or do you want to create a DATE value?&lt;/P&gt;
&lt;P&gt;Either way what do your want to DO with the value?&amp;nbsp; Your example does not show the MONTH value being used in any way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would assume that you want to just generate a date value.&amp;nbsp; Perhaps something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%local offset date1 date2;
%do offset = 0 %to %sysfunc(intck(month,&amp;amp;start,&amp;amp;end)) %by &amp;amp;incr ;
  %let date1 = %sysfunc(intnx(month,&amp;amp;start,&amp;amp;offset));
  %let date2 = %sysfunc(intnx(month,&amp;amp;start,&amp;amp;offset+&amp;amp;incr));
   ...
   where datevar between &amp;amp;date1 and &amp;amp;date2 ;
   ...
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Dec 2018 07:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522444#M141842</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-19T07:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Increment months by macros do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522446#M141844</link>
      <description>&lt;P&gt;I have monthly observations&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 07:24:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522446#M141844</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2018-12-19T07:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Increment months by macros do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522458#M141849</link>
      <description>&lt;P&gt;Please post test data in the form of a datastep:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Its really not worth our time to be guessing what you have!&lt;/P&gt;
&lt;P&gt;As for how you do these things, the simplest cleanest method is to put month into your data a a variable - datasets are where data should go - and then in your proc sgplot you use a by group with the month variable.&amp;nbsp; e.g.:&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=have;
  by month;
run;&lt;/PRE&gt;
&lt;P&gt;This is far simpler coding, will run a lot quicker using less resources.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 09:25:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522458#M141849</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-19T09:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Increment months by macros do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522759#M141978</link>
      <description>&lt;P&gt;thanks. it is indeed the best solution&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 00:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Increment-months-by-macros-do-loop/m-p/522759#M141978</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2018-12-20T00:27:56Z</dc:date>
    </item>
  </channel>
</rss>

