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

Hi,

 

I am attempting to merge two databases. To protect confidentiality, one of the databases had all of it's unique identifiers removed, so there is no single variable that is unique for each subject AND present in both databases that I can use for the merge. HOWEVER, I have found that the combination of two date variables (let's call them VAR1 and VAR2) IS unique for each subject. 

 

Is there any easy way to merge based on these two variables (instead of just using one unique variable which I don't have)? My code is below, but I don't think you can list the two variables this way. I sorted on the two variables first. 

 

Proc sort data=clean.INPROGRESS;

by VAR1 VAR2;

run;

 

proc sort data=clean.ORIGINAL;

by VAR1 VAR2;

run;

 

data clean.COMBINED;

   merge clean.INPROGRESS (in=a) clean.ORIGINAL ;

   by VAR1 VAR2;

   if a;

run;

 

Please help! Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Run it. It should work assuming your analysis of the unique nature of the paired variables is correct.

 

BY processing can use a considerable number of variables. The number doesn't change the basic behavior.

View solution in original post

3 REPLIES 3
LinusH
Tourmaline | Level 20
Haven't you tried it prior to posting?
Doesn't sound correct data wise though to only merge on date variables. Don't you still need some kind of identification of the individuals?
Data never sleeps
ballardw
Super User

Run it. It should work assuming your analysis of the unique nature of the paired variables is correct.

 

BY processing can use a considerable number of variables. The number doesn't change the basic behavior.

Kels123
Quartz | Level 8

Hi,

 

It does work. I just needed to exclude missing VAR1 values from the original databases prior to the merge. Thanks!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 929 views
  • 0 likes
  • 3 in conversation