BookmarkSubscribeRSS Feed
marleeakerson
Calcite | Level 5

Hello, 

 

I am trying to merge two data sets based on claim_numb, but when I do, the Date_Begin_Service_Header variable ends up blank, even though it is completely filled out in data2. 

 

Any advice?

 

proc sort data=data1;
by Claim_Numb;
run;

data data2;
set 
file1(keep=Date_Begin_Service_Header claim_numb)
file2 (keep=Date_Begin_Service_Header claim_numb);
run;
proc sort data=data2; by Claim_Numb; run; data data3; merge data1 (in=a) data2 (in=b) ; by Claim_Numb; if a; run;
3 REPLIES 3
Reeza
Super User
You only keep records that are in A, which is Data1 via the IF statement.
But you say the data is filled out in Data2 not Data1? Should it be the opposite?

Without data, I can only guess....

marleeakerson
Calcite | Level 5

I am trying to merge Data1 with Data2. Data1 has a bunch of variables, including claim_numb. Data2 has only two variables, Date_Begin_Service_Header and claim_numb. I am trying to merge the two tables so I have Data3, which has all the claim_numb from Data1 matched with the Date_Begin_Service_Header variable from Data2. But when I merge, the Date_Begin_Service_Header variable is blank. 

 

 

Reeza
Super User
For all records? That means that the claim numbers never match for some reason. Are they formatted the exact same, ie leading zeros?
Usually it's because their's a mismatch in cases, leading/trailing spaces or invisible blanks that lead to the issue.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 438 views
  • 0 likes
  • 2 in conversation