The core node you are trying to access is permanently deleted.
Hi,
I have this macro, which I run in a loop:
%macro union( input_table, output_table, loop); %if &loop. = 1 %then %do; data &output_table.; set &input_table.; run; %end; %else %do; PROC APPEND BASE= &output_table. DATA= &input_table. force; %end; PROC DELETE DATA= &input_table.; %mend union;
It works well. But I am sure there is better practice to avoid using loop value.
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?
Thanks
You can use proc append with a non-existing base table without problems:
data have;
x1 = 1;
run;
proc append
data=have
base=out
;
run;
Log:
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
The question is, why you have so many related datasets that need appending, such that you need a macro to do this. 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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.