<?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: Appending monthly tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Appending-monthly-tables/m-p/896638#M354310</link>
    <description>&lt;P&gt;You can't treat month designators like consecutive numbers, you need to do some date calculations:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro easy_zero(begin,end);
%local dat;
data easy_zero_rtc;
set
%let dat = %sysfunc(inputn(&amp;amp;begin.,yymmn6.));
%do %while (&amp;amp;dat. le %sysfunc(inputn(&amp;amp;end.,yymmn6.)));
  gen.transact_base_%sysfunc(putn(&amp;amp;dat.,yymmn6.))
  %let dat = %sysfunc(intnx(month,&amp;amp;dat.,1,b));
%end;
; 
keep stamp sub_prod_cde SUB_SEGMENT Account_Type RTC_ONLINE_AMT RTC_BRNCH_AMT RTC_APP_AMT RTC_ONLINE_VOL RTC_BRNCH_VOL RTC_APP_VOL;
where Account_Type ^= 'Credit Card' and sub_prod_cde = 'WX';
run;
%mend easy_zero;

%easy_zero(201909,202308)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 02 Oct 2023 10:21:44 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-10-02T10:21:44Z</dc:date>
    <item>
      <title>Appending monthly tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-monthly-tables/m-p/896633#M354304</link>
      <description>&lt;P&gt;Good day, I have library called GEN which consists of monthly tables from 201801 to 202308 renamed as transact_base_201801 to transact_base_2023.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I need to append the tables from &lt;STRONG&gt;transact_base_201909&lt;/STRONG&gt; till &lt;STRONG&gt;transact_base_202308&lt;/STRONG&gt; using below code and I get the attached error. Kindly assist please&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro easy_zero;
data easy_zero_rtc;
set GEN.TRANSACT_BASE_201909 - GEN.TRANSACT_BASE_202308; 
keep stamp sub_prod_cde SUB_SEGMENT Account_Type RTC_ONLINE_AMT RTC_BRNCH_AMT RTC_APP_AMT RTC_ONLINE_VOL RTC_BRNCH_VOL RTC_APP_VOL;
where Account_Type ^='Credit Card' and sub_prod_cde='WX';
run;
%mend easy_zero;

%easy_zero; &lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Solly7_0-1696241289338.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88460i62E4C456A870F294/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Solly7_0-1696241289338.png" alt="Solly7_0-1696241289338.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 10:08:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-monthly-tables/m-p/896633#M354304</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2023-10-02T10:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Appending monthly tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-monthly-tables/m-p/896636#M354308</link>
      <description>&lt;P&gt;I think the log is pretty self explanatory. A few points though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Using this syntax in the Set Statement assumes that a data set with the name&amp;nbsp;&lt;STRONG&gt;transact_base&lt;/STRONG&gt;&amp;nbsp; and the relevant suffix is available for each integer between 201909 and 202308. That being the &lt;EM&gt;integer&lt;/EM&gt;, not the &lt;EM&gt;date&lt;/EM&gt;. For example, you can see that SAS looks for the data set GEN.TRANSACT_BASE_201913, which is not available and gives an error.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;There is really no need for a macro here.&lt;/LI&gt;
&lt;LI&gt;If you want to stack all the data sets prefixed with&amp;nbsp;TRANSACT_BASE_ in the GEN library you can use the colon operator in the Set Statement like this&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set GEN.TRANSACT_BASE_: ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A small working example, since I can't access your GEN library:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TRANSACT_BASE_201911; x = 1; run;
data TRANSACT_BASE_201912; x = 2; run;
data TRANSACT_BASE_202001; x = 3; run;

data want;
   set TRANSACT_BASE_: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 10:18:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-monthly-tables/m-p/896636#M354308</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-10-02T10:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Appending monthly tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-monthly-tables/m-p/896638#M354310</link>
      <description>&lt;P&gt;You can't treat month designators like consecutive numbers, you need to do some date calculations:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro easy_zero(begin,end);
%local dat;
data easy_zero_rtc;
set
%let dat = %sysfunc(inputn(&amp;amp;begin.,yymmn6.));
%do %while (&amp;amp;dat. le %sysfunc(inputn(&amp;amp;end.,yymmn6.)));
  gen.transact_base_%sysfunc(putn(&amp;amp;dat.,yymmn6.))
  %let dat = %sysfunc(intnx(month,&amp;amp;dat.,1,b));
%end;
; 
keep stamp sub_prod_cde SUB_SEGMENT Account_Type RTC_ONLINE_AMT RTC_BRNCH_AMT RTC_APP_AMT RTC_ONLINE_VOL RTC_BRNCH_VOL RTC_APP_VOL;
where Account_Type ^= 'Credit Card' and sub_prod_cde = 'WX';
run;
%mend easy_zero;

%easy_zero(201909,202308)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Oct 2023 10:21:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-monthly-tables/m-p/896638#M354310</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-02T10:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: Appending monthly tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-monthly-tables/m-p/896639#M354311</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set GEN.TRANSACT_BASE_201909 - GEN.TRANSACT_BASE_202308; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS thinks that this list of data set names goes from integer 201909 to integer 202308, and so what integer comes after 201912? Why 201913, of course, and this data set does not exist. SAS does not know that this is a list of months where 201913 is impossible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You probably could create a list of data set names in library GEN that actually exist, via a macro variable. In this case, we query the dictionary tables to find out what data sets actually exist in GEN, and store the results in a macro variable &amp;amp;DSNAMES&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* UNTESTED CODE */
proc sql noprint;
     select distinct cats('gen.',memname) into :dsnames separated by ' ' from dictionary.tables 
     where libname='GEN' and input(substr(memname,15),6.) between 201909 and 202308;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and then use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set &amp;amp;dsnames;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2023 10:36:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-monthly-tables/m-p/896639#M354311</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-02T10:36:24Z</dc:date>
    </item>
  </channel>
</rss>

