BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Phil_NZ
Barite | Level 11

Hi everyone,

When try to merge two dataset that has some distinct Type in common, I face the problem with the result. even try too out at the log file, I also cannot find where the error comes from. I am wondering if you can have a look and give me a suggestion or else.

 

I have the dataset final (called a).

1.PNG

And I have another raw dataset (called have)

b.PNG

What I want is to match observation in raw data (dataset have) associated with the dataset final based on "Type" and "year" of the dataset final as below (we call dataset want):

c.PNG

By doing this, I use the code as below:

proc sort data=final;
by Type;
run;

proc sort data=have;
by Type;
run;

proc sql;
create Table want as
select a.*,b.*
from final as a, have as b
where (a.Type = b.Type and a.year=b.year);
quit;

And the results as the picture above, but when I check the log, it shows two warnings like that, I am wondering if there is anything wrong in my code or there is anything that I did not concern enough.

 proc sql;
101        create Table merge_ as
102        select a.*,b.*
103        from step4 as a, merge_9_10 as b
104        where (a.Type = b.Type and a.year=b.year);
WARNING: Variable Type already exists on file WORK.MERGE_.
WARNING: Variable year already exists on file WORK.MERGE_.

Thanks in advance!

 
Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

I believe the WARNING in the log is because you used

 

select a.*,b.*

and the WARNING  correctly tells you that both TYPE and YEAR exist in both data sets.

 

The WARNING would go away if you used

 

select a.*,b.isin,b.secd,b.geogn,...

(you can type the rest of the variable names except year)

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

I believe the WARNING in the log is because you used

 

select a.*,b.*

and the WARNING  correctly tells you that both TYPE and YEAR exist in both data sets.

 

The WARNING would go away if you used

 

select a.*,b.isin,b.secd,b.geogn,...

(you can type the rest of the variable names except year)

--
Paige Miller
Phil_NZ
Barite | Level 11
Thanks @Paige Miller, it works for me now!
Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
hellohere
Pyrite | Level 9

any way to remove this warning?!

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2812 views
  • 1 like
  • 3 in conversation