<?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 loop through yearmonth ex 202501 ...202602 in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-loop-through-yearmonth-ex-202501-202602/m-p/983102#M46399</link>
    <description>&lt;P&gt;I find it easier (and generally a good practice) to work with actual SAS dates and let the INTNX function determine the next month. SAS has done the hard work to determine what the next month is, so you don't have to. INTNX has to work with actual SAS dates, not dates that look like dates to humans but are not SAS dates such as 202501. So first I convert the human readable dates to actual SAS dates via the INPUTN function resulting in macro variables &amp;amp;startdate1 and &amp;amp;enddate1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let startdate=202501;
%let enddate=202602;

%let startdate1=%sysfunc(inputn(&amp;amp;startdate,yymmn6.));
%let enddate1=%sysfunc(inputn(&amp;amp;enddate,yymmn6.));

%macro dothis;
    %let thismonth=&amp;amp;startdate1;
    %do %while(&amp;amp;thismonth&amp;lt;=&amp;amp;enddate1);
        %put %sysfunc(putn(&amp;amp;thismonth,yymmn6.));
        %let thismonth=%sysfunc(intnx(month,&amp;amp;thismonth,1,b));
    %end;
%mend;

%dothis&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Feb 2026 20:47:31 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2026-02-05T20:47:31Z</dc:date>
    <item>
      <title>How to loop through yearmonth ex 202501 ...202602</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-loop-through-yearmonth-ex-202501-202602/m-p/983101#M46398</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to do a do loop using two marcro variables&lt;BR /&gt;&lt;BR /&gt;%let startdate=202501;&lt;/P&gt;
&lt;P&gt;%let enddate=202602;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;loop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;202501&lt;/P&gt;
&lt;P&gt;202502&lt;/P&gt;
&lt;P&gt;202503&lt;/P&gt;
&lt;P&gt;202504&lt;/P&gt;
&lt;P&gt;202505&lt;/P&gt;
&lt;P&gt;202506&lt;/P&gt;
&lt;P&gt;202507&lt;/P&gt;
&lt;P&gt;202508&lt;/P&gt;
&lt;P&gt;202509&lt;/P&gt;
&lt;P&gt;202510&lt;/P&gt;
&lt;P&gt;202511&lt;/P&gt;
&lt;P&gt;202512&lt;/P&gt;
&lt;P&gt;202601&lt;/P&gt;
&lt;P&gt;202602&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;</description>
      <pubDate>Thu, 05 Feb 2026 20:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-loop-through-yearmonth-ex-202501-202602/m-p/983101#M46398</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2026-02-05T20:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to loop through yearmonth ex 202501 ...202602</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-loop-through-yearmonth-ex-202501-202602/m-p/983102#M46399</link>
      <description>&lt;P&gt;I find it easier (and generally a good practice) to work with actual SAS dates and let the INTNX function determine the next month. SAS has done the hard work to determine what the next month is, so you don't have to. INTNX has to work with actual SAS dates, not dates that look like dates to humans but are not SAS dates such as 202501. So first I convert the human readable dates to actual SAS dates via the INPUTN function resulting in macro variables &amp;amp;startdate1 and &amp;amp;enddate1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let startdate=202501;
%let enddate=202602;

%let startdate1=%sysfunc(inputn(&amp;amp;startdate,yymmn6.));
%let enddate1=%sysfunc(inputn(&amp;amp;enddate,yymmn6.));

%macro dothis;
    %let thismonth=&amp;amp;startdate1;
    %do %while(&amp;amp;thismonth&amp;lt;=&amp;amp;enddate1);
        %put %sysfunc(putn(&amp;amp;thismonth,yymmn6.));
        %let thismonth=%sysfunc(intnx(month,&amp;amp;thismonth,1,b));
    %end;
%mend;

%dothis&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Feb 2026 20:47:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-loop-through-yearmonth-ex-202501-202602/m-p/983102#M46399</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2026-02-05T20:47:31Z</dc:date>
    </item>
  </channel>
</rss>

