I am working on recurrent events analysis. I have to merge two data sets. The first data set has ID variable as well as t0 (time at the beginning of risk) and t1 (time at event). The second data set has dates of supply of relevant medication. Each ID variable has multiple records in both datasets.
DataSet 1
ID | t0 | t1 | Record |
A | 01 Jan 2017 | 01 Jun 2017 | 1 |
A | 01 Jun 2017 | 31 Dec 2017 | 2 |
B | 01 Feb 2018 | 31 Dec 2018 | 1 |
B | 31 Dec 2018 | 30 Jun 2019 | 2 |
ID | Date of Supply |
A | 01 Nov 2016 |
A | 01 Jan 2017 |
A | 01 Sept 2017 |
A | 01 Oct 2017 |
B | 01 Jan 2018 |
B | 01 Sept 2018 |
B | 01 May 2019 |
B | 01 July 2019 |
B | 01 Sept 2019 |
ID | t0 | t1 | Record | Date of Supply |
A | 01 Jan 2017 | 01 Jun 2017 | 1 | 01 Nov 2016 |
A | 01 Jun 2017 | 31 Dec 2017 | 2 | 01 Jan 2017 |
A | 01 Jun 2017 | 31 Dec 2017 | 2 | 01 Sept 2017 |
A | 01 Jun 2017 | 31 Dec 2017 | 2 | 01 Oct 2017 |
B | 01 Feb 2018 | 31 Dec 2018 | 1 | 01 Jan 2018 |
B | 31 Dec 2018 | 30 Jun 2019 | 2 | 01 Sept 2018 |
B | 31 Dec 2018 | 30 Jun 2019 | 2 | 01 May 2019 |
B | 31 Dec 2018 | 30 Jun 2019 | 2 | 01 July 2019 |
B | 31 Dec 2018 | 30 Jun 2019 | 2 | 01 Sept 2019 |
a. The best way to match the Date of Supply to Record
I thank you in advance.
Regards,
Sateesh
0 Response to Creating additional rows to match dates in column 2 and 3
Post a Comment