BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

I want to merge 2 data sets by char vars.

This example is working well but in real world when I do it I don't succeed. merge the 2 tables well 

The field I want to add has null values (in real world)

Why???

 



  data abc1;
 infile datalines dlm=',';
length x1 $11 x2 $6 ;
 input x1 $ x2 $ ;
 cards;
 AGE_1_VALUE,YESHUT
 ;
 Run;

 data abc2;
 infile datalines dlm=',';
length x1 $11 x2 $6 x3 $10.;
 input x1 $ x2 $ x3 $ ;
 cards;
 AGE_1_VALUE,YESHUT,continuous
 ;
 Run;

proc sql;
create table want as
select a.*,b.x3
from abc1  as a
left join abc2 as b
on compress(upcase(a.x1))=compress(upcase(b.x1)) and compress(upcase(a.x2))=compress(upcase(b.x2))
;
quit;

 

1 REPLY 1
Kurt_Bremser
Super User

Explain in detail what you mean by "don't succeed". Does it throw an ERROR/WARNING or is the result not what you expect?

Anyway, provide examples of the data where this happens.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register 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
  • 1 reply
  • 457 views
  • 0 likes
  • 2 in conversation