<?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: Create a list of months between 2 dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-list-of-months-between-2-dates/m-p/790809#M253213</link>
    <description>&lt;P&gt;What have you tried?&lt;/P&gt;
&lt;P&gt;I would start with a data step creating one observation for each value. Most likely that data set can be used in the subsequent steps, avoiding a list of values in a macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jan 2022 05:50:09 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-01-19T05:50:09Z</dc:date>
    <item>
      <title>Create a list of months between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-list-of-months-between-2-dates/m-p/790807#M253212</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want o get the list of months (in form YYMM) that exists between From_Date and today.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;From_Date&amp;nbsp; is&amp;nbsp; 14MAY2021&lt;/P&gt;
&lt;P&gt;Today is&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;19JAN2022&lt;/P&gt;
&lt;P&gt;I need to create a macro var that will contain the values: 2105+2106+2107+2108+2109+2110+2111+2112+2201&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let From_Date='14MAY2021'd;
%let Today=Today();
/**Task: Need to create a new macro var called vector that will contain list of months in form YYMM between these 2 dates**/
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 05:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-list-of-months-between-2-dates/m-p/790807#M253212</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-01-19T05:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create a list of months between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-list-of-months-between-2-dates/m-p/790809#M253213</link>
      <description>&lt;P&gt;What have you tried?&lt;/P&gt;
&lt;P&gt;I would start with a data step creating one observation for each value. Most likely that data set can be used in the subsequent steps, avoiding a list of values in a macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 05:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-list-of-months-between-2-dates/m-p/790809#M253213</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-01-19T05:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create a list of months between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-list-of-months-between-2-dates/m-p/790824#M253222</link>
      <description>&lt;P&gt;You can do it with a macro, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro monthlist(from_date,to_date=%sysfunc(today())); 
  %local month;                                        
  %do month=%sysfunc(putn(&amp;amp;from_date,yymmn4.)) %to     
            %sysfunc(putn(&amp;amp;to_date,yymmn4.));          
     %if %substr(&amp;amp;month,3)=13 %then                    
        %let month=%eval(&amp;amp;month+88);                   
     %do; &amp;amp;month%end;                                  
     %end;                                             
%mend;

%let vector=%monthlist(&amp;amp;from_date);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or it can be done with a datastep:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;                               
  date=&amp;amp;from_date;                         
  length list $200;                        
  do while(date&amp;lt;=today());                 
    call catx(' ',list,put(date,yymmn4.)); 
    date=intnx('month',date,1);            
    end;                                   
  call symputx('vector',list);             
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jan 2022 08:28:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-list-of-months-between-2-dates/m-p/790824#M253222</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-01-19T08:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create a list of months between 2 dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-list-of-months-between-2-dates/m-p/790871#M253240</link>
      <description>&lt;PRE&gt;%let From_Date='14MAY2021'd;
%let Today=Today();


data _null_;
length list $ 200;
do date=&amp;amp;From_Date to &amp;amp;Today ;
 if month(date) ne month then list=catx('+',list,put(date,yymmn4.));
 month=month(date);
end;
call symputx('list',list);
run;

%put &amp;amp;=list ;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jan 2022 12:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-list-of-months-between-2-dates/m-p/790871#M253240</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-19T12:47:24Z</dc:date>
    </item>
  </channel>
</rss>

