<?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: Macro loop to append dataset with MONYY in the dataset names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-loop-to-append-dataset-with-MONYY-in-the-dataset-names/m-p/831185#M328447</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lstmonth;
  do i=0 to 13;
    dates=cats('XXX_',put(intnx('month',today(),-i,'s'),monyy.));
    output;
  end;
run;

proc sql noprint;
    select dates into :datlst separated by ' '
    from lstmonth ;
quit;&lt;BR /&gt;
%put &amp;amp;=datlst;&lt;BR /&gt;&lt;BR /&gt;/*  you will get this list: &lt;BR /&gt;DATLST=&lt;BR /&gt;XXX_AUG22 XXX_JUL22 XXX_JUN22 XXX_MAY22 XXX_APR22 XXX_MAR22 XXX_FEB22 XXX_JAN22 XXX_DEC21 XXX_NOV21 XXX_OCT21 XXX_SEP21 XXX_AUG21 XXX_JUL21&amp;nbsp;&lt;BR /&gt;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;*/&lt;BR /&gt;&lt;BR /&gt;data combined;&lt;BR /&gt;set &amp;amp;datlst &lt;BR /&gt;  indsname = source; /* the INDSNAME= option stores the dataset name */&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 31 Aug 2022 15:39:12 GMT</pubDate>
    <dc:creator>ghosh</dc:creator>
    <dc:date>2022-08-31T15:39:12Z</dc:date>
    <item>
      <title>Macro loop to append dataset with MONYY in the dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-loop-to-append-dataset-with-MONYY-in-the-dataset-names/m-p/831171#M328445</link>
      <description>&lt;P&gt;Hi team,&lt;/P&gt;&lt;P&gt;I am looking to create one master table which contains 13 months worth of data.&lt;/P&gt;&lt;P&gt;Currently the table names are as such:&lt;/P&gt;&lt;P&gt;XXX_AUG22&lt;/P&gt;&lt;P&gt;XXX_JUL22&lt;/P&gt;&lt;P&gt;XXX_JUN22&lt;/P&gt;&lt;P&gt;... etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to append these tables using a macro loop by combining this month's data + the last 12 months?&lt;/P&gt;&lt;P&gt;Appreciate your help!&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 00:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-loop-to-append-dataset-with-MONYY-in-the-dataset-names/m-p/831171#M328445</guid>
      <dc:creator>boomboomtanner</dc:creator>
      <dc:date>2022-08-31T00:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macro loop to append dataset with MONYY in the dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-loop-to-append-dataset-with-MONYY-in-the-dataset-names/m-p/831185#M328447</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lstmonth;
  do i=0 to 13;
    dates=cats('XXX_',put(intnx('month',today(),-i,'s'),monyy.));
    output;
  end;
run;

proc sql noprint;
    select dates into :datlst separated by ' '
    from lstmonth ;
quit;&lt;BR /&gt;
%put &amp;amp;=datlst;&lt;BR /&gt;&lt;BR /&gt;/*  you will get this list: &lt;BR /&gt;DATLST=&lt;BR /&gt;XXX_AUG22 XXX_JUL22 XXX_JUN22 XXX_MAY22 XXX_APR22 XXX_MAR22 XXX_FEB22 XXX_JAN22 XXX_DEC21 XXX_NOV21 XXX_OCT21 XXX_SEP21 XXX_AUG21 XXX_JUL21&amp;nbsp;&lt;BR /&gt;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;*/&lt;BR /&gt;&lt;BR /&gt;data combined;&lt;BR /&gt;set &amp;amp;datlst &lt;BR /&gt;  indsname = source; /* the INDSNAME= option stores the dataset name */&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Aug 2022 15:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-loop-to-append-dataset-with-MONYY-in-the-dataset-names/m-p/831185#M328447</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2022-08-31T15:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Macro loop to append dataset with MONYY in the dataset names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-loop-to-append-dataset-with-MONYY-in-the-dataset-names/m-p/831193#M328451</link>
      <description>&lt;P&gt;As a&amp;nbsp;&lt;STRONG&gt;very big&lt;/STRONG&gt; hint for the future: never use date strings like these in dataset names or similar. Use a YYYYMM string instead.&lt;/P&gt;
&lt;P&gt;You can then combine a year simply like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have_2022:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In all displays, the datasets will always sort in chronological order.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 05:32:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-loop-to-append-dataset-with-MONYY-in-the-dataset-names/m-p/831193#M328451</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-08-31T05:32:09Z</dc:date>
    </item>
  </channel>
</rss>

