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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 473 views
  • 0 likes
  • 2 in conversation