BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jacksonan123
Lapis Lazuli | Level 10

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:

 
NOTE: Appending WORK.KLALL2 to WORK.KLALL.
WARNING: Variable skl2 was not found on BASE file. The variable will not be added to the BASE file.
WARNING: Variable skl1 was not found on DATA file.
NOTE: FORCE is specified, so dropping/truncating will occur.
NOTE: There were 1 observations read from the data set WORK.KLALL2.
NOTE: 1 observations added.
 
How can I get the following final data set KLALL that I want?
 

KLALL:

_type_     _freq_     skl1

0               22           0.41

0               22           0.47

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
s_lassen
Meteorite | Level 14

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.

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26
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?

 

 

--
Paige Miller
s_lassen
Meteorite | Level 14

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.

ballardw
Super User

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.

jacksonan123
Lapis Lazuli | Level 10
A summary confidence interval will be calculated so data order is not important.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 997 views
  • 0 likes
  • 4 in conversation