<?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: PROC APPEND - Loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Loop/m-p/378934#M91131</link>
    <description>&lt;P&gt;The question is, why you have so many related datasets that need appending, such that you need a macro to do this. &amp;nbsp;I would suggest you look into By Group processing, which is a core SAS feature used to do operations on groups of data, as I suspect your running procedures of blocks of data individually yourself, and then setting them back together again at the end.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jul 2017 11:46:48 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-07-25T11:46:48Z</dc:date>
    <item>
      <title>PROC APPEND - Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Loop/m-p/378931#M91128</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this macro, which I run&amp;nbsp;in a loop:&lt;/P&gt;&lt;PRE&gt;%macro union(
	input_table,
	output_table,
	loop);

%if &amp;amp;loop. = 1 %then %do;
	data &amp;amp;output_table.; set &amp;amp;input_table.; run;
%end;
%else %do;
	PROC APPEND BASE= &amp;amp;output_table. DATA= &amp;amp;input_table. force;
%end;
PROC DELETE DATA= &amp;amp;input_table.;
%mend union;&lt;/PRE&gt;&lt;P&gt;It works well. But I am sure there is better practice to avoid using loop value.&lt;/P&gt;&lt;P&gt;Is there a way for the Proc APPEND to detect if the output_table exists, and if not to create it naturally with the input table?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 11:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Loop/m-p/378931#M91128</guid>
      <dc:creator>FP12</dc:creator>
      <dc:date>2017-07-25T11:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: PROC APPEND - Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Loop/m-p/378933#M91130</link>
      <description>&lt;P&gt;You can use proc append with a non-existing base table without problems:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
x1 = 1;
run;

proc append
  data=have
  base=out
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;24         data have;
25         x1 = 1;
26         run;

NOTE: The data set WORK.HAVE has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

27         
28         proc append
29           data=have
30           base=out
31         ;
32         run;

NOTE: Appending WORK.HAVE to WORK.OUT.
NOTE: BASE data set does not exist. DATA file is being copied to BASE file.
NOTE: There were 1 observations read from the data set WORK.HAVE.
NOTE: The data set WORK.OUT has 1 observations and 1 variables.
NOTE: PROCEDURE APPEND used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Jul 2017 11:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Loop/m-p/378933#M91130</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-25T11:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: PROC APPEND - Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Loop/m-p/378934#M91131</link>
      <description>&lt;P&gt;The question is, why you have so many related datasets that need appending, such that you need a macro to do this. &amp;nbsp;I would suggest you look into By Group processing, which is a core SAS feature used to do operations on groups of data, as I suspect your running procedures of blocks of data individually yourself, and then setting them back together again at the end.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 11:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Loop/m-p/378934#M91131</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-25T11:46:48Z</dc:date>
    </item>
  </channel>
</rss>

