BookmarkSubscribeRSS Feed
ss812
Calcite | Level 5

I have 2 files of different types of data that I am trying to combine. One file includes information on patient cancer status and the other file includes information on patient demographic and assessment information. The two files both have patient last name and date of service in common (along with a few other variables-but these two are the ones I am trying to combine on), I cannot combine on just patient last name because some patients appear multiple times in the both datasets with different dates of service, so both last name and date of service are needed to identify the specific cases and match the information. My end goal is to have one file that has both the information on patient cancer status and on patient demographic & assessment information in a single file, with each row representing 1 case (and eliminating any patients who don't have a complete set of data from both portions). Is there a way to do this in the data merge steps (and to delete any cases that do not have data available from both data sets)?

2 REPLIES 2
Jim_G
Pyrite | Level 9

 

Your code would be something like this:

 

/* I have called the patient date set pat and the service data serv.

   merge moves info from the right dataset (serv) into the left dataset (pat)  */;

 

proc sort data= pat;  by lastname dateserv;

 

proc sort data=serv;  by lastname dateserv;

 

data want;   merge pat (in=inpat)  serv (in=inserv) ;  by lastname dateserv;

 

if inpat and inserv then output;

 

Jim

ballardw
Super User

I am a bit concerned that you are only going to use a LAST name and service date.

It is extremely likely that common last names, Smith or Rodriguez for a pair of examples, may have multiple patients associated on any given date. John Smith, Mary Smith, etc. And if you have new born children then multiple births will cause issues.

I suspect that you want at least one other variable. I know that my hospital asks me for date of birth every time they start to do anything: draw blood, take a weight, blood pressure, administer medication ...

Or see if your organization has a patient id or account variable that is supposed to be unique for each patient.

 

Names are often one of the last things you want to work with if possible. Also some folks change last names, data entry errors.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 707 views
  • 1 like
  • 3 in conversation