<?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: Run macro 60 times in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923570#M363589</link>
    <description>&lt;P&gt;You create 6 macro variables that are one month apart, lets call them &amp;amp;DATE1 through &amp;amp;DATE6 where initially &amp;amp;date1 is the date corresponding to 2206, and then &amp;amp;DATE2 is one month after &amp;amp;DATE1, and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you create a loop with index &amp;amp;I that goes 1 to 59, and each time &amp;amp;DATE1 is decreased by &amp;amp;I months, and then &amp;amp;DATE2 through &amp;amp;DATE6 are recalculated accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please give it a try.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do not try to do this with dates as integers like 2206. YOu want to do this with actual SAS date values, which are the number of days since 01JAN1960, formatted as YYMMN4.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Apr 2024 11:24:51 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-04-09T11:24:51Z</dc:date>
    <item>
      <title>Run macro 60 times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923565#M363587</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to run macro that contain 6 arguments.&lt;/P&gt;
&lt;P&gt;I want to run it X60 times (Each time with different macro arguments)&lt;/P&gt;
&lt;P&gt;Each argument contain value in format YYMM&lt;/P&gt;
&lt;P&gt;Here is the require macro run: (60 runs)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%RRR(M6=2211,M5=2210,M4=2209,M3=2208,M2=2207,M1=2206)
%RRR(M6=2210,M5=2209,M4=2208,M3=2207,M2=2206,M1=2205)
%RRR(M6=2208,M5=2208,M4=2207,M3=2206,M2=2205,M1=2204)
and so on
%RRR(M6=1801,M5=1712,M4=1711,M3=1710,M2=1709,M1=1708)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is the best way to create the code that it 60 times as I mentioned?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2024 11:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923565#M363587</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-04-09T11:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro 60 times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923568#M363588</link>
      <description>&lt;P&gt;Did you at least tried to "google" it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1712661593185.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95344iF0E9943E4027AAD0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1712661593185.png" alt="yabwon_0-1712661593185.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2024 11:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923568#M363588</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-04-09T11:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro 60 times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923570#M363589</link>
      <description>&lt;P&gt;You create 6 macro variables that are one month apart, lets call them &amp;amp;DATE1 through &amp;amp;DATE6 where initially &amp;amp;date1 is the date corresponding to 2206, and then &amp;amp;DATE2 is one month after &amp;amp;DATE1, and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you create a loop with index &amp;amp;I that goes 1 to 59, and each time &amp;amp;DATE1 is decreased by &amp;amp;I months, and then &amp;amp;DATE2 through &amp;amp;DATE6 are recalculated accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please give it a try.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do not try to do this with dates as integers like 2206. YOu want to do this with actual SAS date values, which are the number of days since 01JAN1960, formatted as YYMMN4.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2024 11:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923570#M363589</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-09T11:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro 60 times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923572#M363591</link>
      <description>&lt;P&gt;May you please show code?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2024 11:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923572#M363591</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-04-09T11:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro 60 times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923574#M363592</link>
      <description>&lt;P&gt;Please give it a try. From your other questions, I know you have written macros before.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2024 11:31:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923574#M363592</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-09T11:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro 60 times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923575#M363593</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro RRR(M6=I,M5=am,M4=lazy,M3=and,M2=not,M1=googling);
%put &amp;amp;M6. &amp;amp;M5. &amp;amp;M4. &amp;amp;M3. &amp;amp;M2. &amp;amp;M1.;
%mend RRR;

%RRR();

data _Null_;
  startdate="01nov2022"d;
  do i = 0 to 59; /* 60 times including current month */
    array M[0:5] $4 M6-M1;
      length str $ 512;
      str=" ";
      do j=0 to 5;
        sd=intnx("month",startdate,-i-j,"S");
        M[j] = cats(mod(year(sd),100),put(month(sd),z2.));
        str=catx(",",str,catx("=",vname(M[j]),M[j]));
      end;
      call execute('%nrstr(%RRR(' !! strip(str) !! '))');
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Apr 2024 11:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923575#M363593</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-04-09T11:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro 60 times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923577#M363595</link>
      <description>&lt;P&gt;Why don't you just use format YYMMN4. instead of&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cats(mod(year(sd),100),put(month(sd),z2.));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Apr 2024 11:38:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923577#M363595</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-09T11:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro 60 times</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923578#M363596</link>
      <description>&lt;P&gt;Good point, updated:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro RRR(M6=I,M5=am,M4=lazy,M3=and,M2=not,M1=googling);
%put &amp;amp;M6. &amp;amp;M5. &amp;amp;M4. &amp;amp;M3. &amp;amp;M2. &amp;amp;M1.;
%mend RRR;

%RRR();

data _Null_;
  startdate="01nov2022"d;
  do i = 0 to 59;
    array M[0:5] $4 M6-M1;
      length str $ 512;
      str=" ";
      do j=0 to 5;
        sd=intnx("month",startdate,-i-j,"S");
        str=catx(",",str,catx("=",vname(M[j]),put(sd,YYMMN4.)));
      end;
      call execute('%nrstr(%RRR(' !! strip(str) !! '))');
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Apr 2024 11:42:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-60-times/m-p/923578#M363596</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-04-09T11:42:15Z</dc:date>
    </item>
  </channel>
</rss>

