Hi,
I have a data set with patient duplicates. I need to remove duplicates depending on certain dates and conditions (events).
For "disease" = Auris, keep only the first observation if "id" and "DOB" are identical. Remove all other observations.
For "disease" = Acino, keep only first and last obs if "id" and "DOB" are identical.
For "disease" = CRE, if "id" and "DOB" are identical, keep the first observation and next observation(s) if they have a date difference of more than 12 months from the previous observation. Else keep the first obs and delete the observations with a < 12 months date difference.
I've uploaded a mini-sheet that has the original data and an image for the resulted deduplicated data.
Please advise.
I have a data set with patient duplicates. I need to remove duplicates depending on certain dates and conditions (events).
For "disease" = Auris, keep only the first observation if "id" and "DOB" are identical. Remove all other observations.
For "disease" = Acino, keep only first and last obs if "id" and "DOB" are identical.
For "disease" = CRE, if "id" and "DOB" are identical, keep the first observation and next observation(s) if they have a date difference of more than 12 months from the previous observation. Else keep the first obs and delete the observations with a < 12 months date difference.
I've uploaded a mini-sheet that has the original data and an image for the resulted deduplicated data.
Please advise.
testdedup (3).xlsx | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | Id | Disease | DOB | Date | ||
2 | 123 | Auris | 1/8/1961 | 1/1/2018 | ||
3 | 123 | CRE | 1/8/1961 | 9/2/2020 | ||
4 | 344 | CRE | 2/12/1956 | 8/6/2019 | ||
5 | 344 | CRE | 2/12/1956 | 3/6/2020 | ||
6 | 344 | CRE | 2/12/1956 | 3/3/2022 | ||
7 | 323 | CRE | 7/1/1993 | 1/6/2019 | ||
8 | 323 | CRE | 7/1/1993 | 9/6/2020 | ||
9 | 323 | CRE | 7/1/1993 | 9/30/2020 | ||
10 | 167 | Acino | 12/9/2001 | 3/6/2019 | ||
11 | 167 | Acino | 12/9/2001 | 4/30/2020 | ||
12 | 167 | Acino | 12/9/2001 | 9/3/2021 | ||
13 | 912 | CRE | 3/1/2012 | 3/3/2018 | ||
14 | 912 | CRE | 3/1/2012 | 5/6/2019 | ||
15 | 912 | CRE | 3/1/2012 | 9/6/2020 | ||
16 | 256 | Auris | 5/27/1983 | 8/5/2020 | ||
17 | 256 | Auris | 5/27/1983 | 12/7/2020 | ||
18 | 256 | Auris | 5/27/1983 | 10/7/2021 | ||
19 | 256 | Auris | 5/27/1983 | 2/7/2022 | ||
20 | 317 | Acino | 7/17/1985 | 12/7/2018 | ||
21 | 317 | Acino | 7/17/1985 | 1/3/2018 | ||
22 | 409 | CRE | 8/7/1987 | 3/3/2018 | ||
23 | 409 | CRE | 8/7/1987 | 5/6/2019 | ||
24 | 409 | CRE | 8/7/1987 | 9/6/2019 | ||
25 | 409 | CRE | 8/7/1987 | 10/6/2021 | ||
Testdedup |