I have one dataset (HOSP) with hospitalization data and another (EVENT) with procedure data. How can I merge these two so that I get a match whenever a procedure was done during a matching hospitalization? The problem is that the data in EVENT may not exactly match any field in HOSP.
Example:
So I want my output to have 5 records, merging (A) in HOSP with each (A) in EVENT, (B) with (B) and (C) with (C).
One attempt didn’t work-- I tried to sort HOSP by “ID” and “start” and EVENT by “ID” and “date”, then merge by ID only (since the dates won’t necessarily be an exact match).
Any thoughts? Thanks!
Example:
Code:
***** HOSP *****
ID start end
1) 099 04/12/2000 04/15/2000
2) 157 02/28/2000 03/01/2000
3) 157 05/15/2001 06/04/2001 (A)
4) 157 08/12/2001 08/20/2001
5) 157 10/03/2001 10/04/2001 (B)
6) 228 03/12/1997 03/15/1997
7) 228 09/12/2001 09/18/2001 (C)
***** EVENT *****
ID procedure date
1) 099 surgery 07/18/1998
2) 157 biopsy 05/20/2001 (A)
3) 157 x-ray 06/02/2001 (A)
4) 157 blood work 06/02/2001 (A)
5) 157 MRI 09/17/2001
6) 157 surgery 10/03/2001 (B)
7) 228 surgery 09/14/2001 (C)
8) 228 blood work 11/29/2002
So I want my output to have 5 records, merging (A) in HOSP with each (A) in EVENT, (B) with (B) and (C) with (C).
One attempt didn’t work-- I tried to sort HOSP by “ID” and “start” and EVENT by “ID” and “date”, then merge by ID only (since the dates won’t necessarily be an exact match).
Any thoughts? Thanks!