I have two data sets which I have produced from the following macro code
PROC MEANS DATA=MERGFIN&K noprint;
VAR KL&K ;
OUTPUT OUT=KLALL&K sum=skl&K ;
RUN;
The data sets klall1 :
_type_ _freq_ skl1
0 22 0.41
and klaa2
_type_ _freq_ skl1
0 22 0.47
When I use the append code
PROC APPEND BASE=KLALL DATA=KLALL&K FORCE;
*PROC PRINT;
RUN;
I get the following warning:
KLALL:
_type_ _freq_ skl1
0 22 0.41
0 22 0.47
I think you misread the macro code and the variable headers in your KLALL2 table. The summary variable is not called SKL1, but SKL2, that's the problem.
The easy way to solve the problem seems to be to change the SUM= part of the OUTPUT statement in PROC MEANS:
OUTPUT OUT=KLALL&K sum=skl1 ;
That way, the summary variable will be named SKL1 in all your temporary outputs.
The data sets klall1 : _type_ _freq_ skl1 0 22 0.41 and klaa2 _type_ _freq_ skl1 0 22 0.47
Your data, as presented, does not match what SAS is telling you. There is no SKL2 in the data you present, yet SAS finds it an decides this is an error. Could you please clarify?
I think you misread the macro code and the variable headers in your KLALL2 table. The summary variable is not called SKL1, but SKL2, that's the problem.
The easy way to solve the problem seems to be to change the SUM= part of the OUTPUT statement in PROC MEANS:
OUTPUT OUT=KLALL&K sum=skl1 ;
That way, the summary variable will be named SKL1 in all your temporary outputs.
This may be a silly question but after you have all of these proc means results appended together how do you know which data set any specific value came from? Or the original variable?
Relying on order of appearance in a data set to indicate source or other properties is generally a very poor idea.
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.