I have two datasets that I want to merg- One from the screening registry and the other one from a hospital registry. I want to include the hospital data into the screening dataset. However, I want the hospital data to be included in the row where date of screening is earlier than the date of diagnosis. For example, if someone got screened in October 2007 and November 2018 (screening data) and diagnosed with the disease in December 2007 (hospital data), I want the hospital data for that person to be included in the row of October 2007 screening data. An example is below.
Any help on how to write the syntax for this. Thank you.
Data: Screening
ID Gender date_screened
1 1 01Nov2000
1 1 05Oct2003
1 1 01Oct2006
1 1 02Mar2008
2 2 01Feb2000
2 2 17Apr2003
2 2 09June2005
2 2 07Oct2008
3 1 08Dec2008
4 1 01Oct2006
4 1 02Mar2008
5 1 17Apr2003
Data: hospital
ID Disease_type Date_diagnosis
1 1 02Nov2001
2 1 13June2004
2 2 08July2005
3 1 16Nov2013
5 1 18Apr2005
Combine to (an example) :
ID Gender Date_screened Disease_type Date_diagnosis
1 1 01Nov2000 1 02Nov2001
1 1 05Oct2003
1 1 01Oct2006
1 1 02March2008
2 2 01Feb2000
2 2 17Apr2003 1 13June2004
2 2 09June2005 2 08July2005
2 2 07Oct2008
3 1 08Dec2008 1 16Nov2013
4 1 01Oct2006
4 1 02Mar2008
5 1 17Apr2003 1 18Apr2005
Related Posts with Merging datasets
Multiple treatmentsHi I have a panel of roughly 1000 firms across 10 years (2004-2013) in 2 states in the US (CA and PA…
String variable to date formatHi, I am encountered with a problem in converting a string variable to date format to enable time s…
period to period changeDear Stata users, The dataset I am working on is repeated measures data and it looks as below. I wa…
How to create a dummy within a categorical variable.Hello everyone, i am working on Mergers and Acquisition. I have a variable named "Acquirer Name" whi…
How to import large mdb fileHi, I have to import large .mdb files and transfer into stata file. As the databases are saved in 3…
Subscribe to:
Post Comments (Atom)
0 Response to Merging datasets
Post a Comment