<?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: Data Appending in a Loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375146#M276427</link>
    <description>&lt;P&gt;Here's a one way that's&amp;nbsp;damn easy to code but may not be the most efficient &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This assumes you're only appending data and would replace your entire program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let year1 = 2000;
%let year2 = 2011;
%let year3 = 2012;
%let year4 = 2017;

data want;
 set 
     ibs_arc.dsup&amp;amp;year1. - ibs_arc.dsup&amp;amp;year2. 
     ibs_arc.dsup&amp;amp;year3. - ibs_arc.dsup&amp;amp;year4. ;
 run;&lt;/CODE&gt;&lt;/PRE&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>Tue, 11 Jul 2017 22:03:00 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-07-11T22:03:00Z</dc:date>
    <item>
      <title>Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375122#M276422</link>
      <description>&lt;P&gt;Every month we run the following to create data files:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro getdata;
%let year1 = 2000;
%let year2 = 2011;
%let year3 = 2012;
%let year4 = 2017;

%do i = &amp;amp;year1 %to &amp;amp;year2;
	data egtask.dailysup_&amp;amp;i.;set ibs_arc.dsup&amp;amp;i.;run;
%end;

%do i = &amp;amp;year3 %to &amp;amp;year4;
	data egtask.dailysup_&amp;amp;i.;set ibs.dsup&amp;amp;i.;run;
%end;
%mend getdata;
%getdata;

PROC SQL;
CREATE TABLE SASCOMB.DAILY_SUP_APPEND AS 
SELECT * FROM EGTASK.DAILYSUP_2000
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2001
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2002
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2003
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2004
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2005
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2006
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2007
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2008
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2009
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2010
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2011
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2012
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2013
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2014
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2015
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2016
 OUTER UNION CORR 
SELECT * FROM EGTASK.DAILYSUP_2017
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see, the&amp;nbsp;sql command is not very elegant. Is it possible to put it into a loop so one would just be able to use the year variables at the start of the macro to make the table? This way we would not need to add a new select * line at the end of every year; it would just be fully automated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 20:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375122#M276422</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2017-07-11T20:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375128#M276423</link>
      <description>&lt;P&gt;Assuming your code works fine, you can replace the SQL step with next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro join(ystart,yend);
%DO;
     PROC SQL;
     CREATE TABLE SASCOMB.DAILY_SUP_APPEND AS 
  %do year=&amp;amp;ystart %to &amp;amp;yend;
      SELECT * FROM EGTASK.DAILYSUP_&amp;amp;year
       OUTER UNION CORR 
  %end;
   ; QUIT;&lt;BR /&gt;%END;
%mend join;
%join(2000,2017);

 

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jul 2017 20:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375128#M276423</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-11T20:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375129#M276424</link>
      <description>&lt;P&gt;Potentially, there is a lot wrong with this process.&amp;nbsp; Making the code more elegant by setting up a loop?&amp;nbsp; No way.&amp;nbsp; That would just hide the bad features that are already built in so that they would never get changed.&amp;nbsp; Let's take a look under the hood here ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the underlying data for years 2000 to 2016 ever change?&amp;nbsp; If not, why not just save the combined result through 2016 permanently.&amp;nbsp; Then you can add in the data for 2017 monthly, to create an up-to-date picture.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why copy data sets to the EGTASK library?&amp;nbsp; That's a waste of resources.&amp;nbsp; SQL can operate on the original data from the IBS and IBS_ARC libraries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Trying to add macro loops to cover up the blemishes?&amp;nbsp; Not the right solution.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 20:55:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375129#M276424</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-11T20:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375130#M276425</link>
      <description>&lt;P&gt;Wouldn't PROC APPEND be more efficient, even if you did have to do it monthly?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 20:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375130#M276425</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-11T20:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375142#M276426</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;.&lt;BR /&gt;&lt;BR /&gt;I have inherited this code and I come from an eviews background, so bear with me. Yes the past data can change, so it needs to be rerun. Can you elaborate on using the original data from the libraries as opposed to copying to EGTASK? How would this be implemented with Shmuel's idea.&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Tue, 11 Jul 2017 21:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375142#M276426</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2017-07-11T21:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375146#M276427</link>
      <description>&lt;P&gt;Here's a one way that's&amp;nbsp;damn easy to code but may not be the most efficient &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This assumes you're only appending data and would replace your entire program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let year1 = 2000;
%let year2 = 2011;
%let year3 = 2012;
%let year4 = 2017;

data want;
 set 
     ibs_arc.dsup&amp;amp;year1. - ibs_arc.dsup&amp;amp;year2. 
     ibs_arc.dsup&amp;amp;year3. - ibs_arc.dsup&amp;amp;year4. ;
 run;&lt;/CODE&gt;&lt;/PRE&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>Tue, 11 Jul 2017 22:03:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375146#M276427</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-11T22:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375158#M276428</link>
      <description>&lt;P&gt;Before we get to any macro language, picture this code as a goal:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;PROC&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;SQL&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
CREATE &lt;SPAN class="token statement"&gt;TABLE&lt;/SPAN&gt; SASCOMB&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DAILY_SUP_APPEND AS 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs_arc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP_2000
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs_arc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2001
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs_arc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2002
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs_arc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2003
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs_arc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2004
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs_arc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2005
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs_arc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2006
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs_arc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2007
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs_arc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2008
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs_arc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2009
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs_arc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2010
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs_arc&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2011
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2012
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2013
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2014
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2015
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2016
 OUTER UNION &lt;SPAN class="token procnames"&gt;CORR&lt;/SPAN&gt; 
&lt;SPAN class="token statement"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; ibs&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;DSUP2017
&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Copying the data sets from their original locations almost certainly represents an extra unnecessary step (unless the EGTASK folder also needs to contain a separate copy of the data).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could the SQL code be replaced with something better? &amp;nbsp;I'm not sure. &amp;nbsp;I don't know enough about how OUTER UNION CORR works to combine files. &amp;nbsp;If that's the right way to go, Schmuel's idea is close. &amp;nbsp;It does generate the words OUTER UNION CORR an extra time, but that can be addressed by macro language.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 22:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375158#M276428</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-11T22:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375162#M276429</link>
      <description>&lt;P&gt;The reason they are copied to EGTASK, is that IT has some of the data as "current" (last few years), while older stuff is in an archive folder. This way the data to append is all in one spot. I do like Shmuel's idea and I can see it work, but it could also be nicer not to copy the data locally to EGTASK, as Astounding notes. Not sure it is worth the effort, but could his idea be modified to get data from the two sources? &amp;nbsp;Maybe not worth the effort.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 23:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375162#M276429</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2017-07-11T23:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375167#M276430</link>
      <description>&lt;P&gt;Your archive data isn't changing is it? You can make that your 'base' table and append to it once, you shouldn't combine them all each time.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 00:46:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375167#M276430</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-12T00:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375176#M276431</link>
      <description>&lt;P&gt;Based on&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;'s&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s notes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming archieve data desn't change, then create base - run it &lt;U&gt;&lt;STRONG&gt;once&lt;/STRONG&gt;&lt;/U&gt; - as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data egtask.dsup2000_2011;
      set ibs_arc.dsup2000 - ibs_arc.dsuo2011;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After successfull run you can deside if to cancel it from archieve or keep for backup;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;having the base created, you can continue monthly with next code, either:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data SASCOMB.DAILY_SUP_APPEND;
    set egtask.dsup2000_2011    /* the base file */
          ibs.dsup2012 - ibs.dsup2017
   ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or using my fixed code addapted to above:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro join(ystart,yend);
%DO;
     PROC SQL;
     CREATE TABLE SASCOMB.DAILY_SUP_APPEND AS 
     select * from egtask.dsup2000_2011
  %do year=&amp;amp;ystart %to &amp;amp;yend;
      outer union corr
      SELECT * FROM EGTASK.DAILYSUP_&amp;amp;year
  %end;
   ; QUIT;
%END;
%mend join;
%join(2012,2017);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 01:57:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375176#M276431</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-12T01:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375180#M276432</link>
      <description>&lt;P&gt;On 2nd thought - why copy archive data - maybe creating the base as a view will be more efficient:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data egtask.dsup2000_2011 / view=egtask.dsup2000_2011;
      set ibs_arc.dsup2000 - ibs_arc.dsuo2011;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jul 2017 02:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375180#M276432</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-12T02:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375217#M276433</link>
      <description>&lt;P&gt;BCNAV,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you're looking in the right direction ... what's the process, what does it need to be, what could it become?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question: &amp;nbsp;When you say the data for past years could change, does that include the earlier archived years (2000 to 2011)? &amp;nbsp;If those years are fixed, they could be combined and saved that way to speed up the monthly process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question for the board: &amp;nbsp;What does OUTER UNION CORR do? &amp;nbsp;Is it identical to concatenating the data sources in a SET statement, or does it imply some other result? &amp;nbsp;Don't make me message&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 06:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375217#M276433</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-12T06:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375239#M276434</link>
      <description>&lt;P&gt;SQL - OUTER UNION CORR -&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next documentation taken from:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://v8doc.sas.com/sashtml/proc/zueryexp.htm" target="_self"&gt;https://v8doc.sas.com/sashtml/proc/zueryexp.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;CORRESPONDING (CORR) Keyword
The CORRESPONDING keyword is used only when a set operator is specified. &lt;BR /&gt;CORR causes PROC SQL to match the columns in table-expressions by name and not by ordinal position. &lt;BR /&gt;Columns that do not match by name are excluded from the result table, except for the OUTER UNION operator. See OUTER UNION .

For example, when performing a set operation on two table-expressions, &lt;BR /&gt;PROC SQL matches the first specified column-name (listed in the SELECT clause) &lt;BR /&gt;from one table-expression with the first specified column-name from the other. &lt;BR /&gt;If CORR is omitted, PROC SQL matches the columns by ordinal position.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 08:47:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375239#M276434</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-12T08:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375316#M276435</link>
      <description>&lt;P&gt;In an effort to keep things simple for others, I decided to use the simpler code by Shmuel (despite my liking of macros and loops). Everyone can understand it, is intuitive, and can easily be changed. Thanks to all!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Use a view as a "virtual dataset" so that data is not compiled unnecessarily */
data egtask.dsup2000_2011 / view=egtask.dsup2000_2011;
      set ibs_arc.dsup2000 - ibs_arc.dsup2011;
run;
data SASCOMB.DAILY_SUP_APPEND_2;
    set egtask.dsup2000_2011    /* The base file view from above*/
          ibs.dsup2012 - ibs.dsup2017
   ;
run;
proc sql; drop view egtask.dsup2000_2011; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;d&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 14:39:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375316#M276435</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2017-07-12T14:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375328#M276436</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/142314"&gt;@BCNAV&lt;/a&gt;&amp;nbsp;Please mark one of his answers as the solution.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 14:37:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375328#M276436</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-12T14:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Data Appending in a Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375330#M276437</link>
      <description>&lt;P&gt;Done! Thanks for reminding me.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 14:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Appending-in-a-Loop/m-p/375330#M276437</guid>
      <dc:creator>BCNAV</dc:creator>
      <dc:date>2017-07-12T14:38:33Z</dc:date>
    </item>
  </channel>
</rss>

