Hello,
I have a dataset with claims of medication, each line / observation is one claim. I have the patient_ID, the date of the claim, and the medication. Now I created a variable, which defines the event (claim of a specific medication x, newuse=1). Here is a sample dataset:
patient_ID
date_claim
medication
newuse
1
17.06.2016
Medication
0
1
30.08.2019
Medication
0
1
30.08.2019
Medication
0
1
23.09.2019
Medication
0
1
23.09.2019
Medication
0
1
23.09.2019
Medication
0
1
23.09.2019
Medication
0
1
24.10.2019
Medication X
1
1
22.11.2019
Medication
0
1
03.03.2020
Medication
0
1
15.07.2020
Medication
0
1
02.03.2021
Medication
0
1
15.11.2021
Medication
0
2
27.01.2017
Medication
0
2
24.08.2018
Medication
0
2
14.09.2018
Medication
0
2
24.09.2018
Medication
0
2
19.10.2018
Medication
0
2
16.11.2018
Medication
0
2
01.02.2019
Medication
0
2
01.02.2019
Medication X
1
2
08.04.2019
Medication
0
2
06.05.2019
Medication
0
2
04.11.2019
Medication
0
2
04.11.2019
Medication
0
2
27.03.2020
Medication
0
2
21.06.2021
Medication
0
2
14.12.2021
Medication
0
3
25.06.2018
Medication
0
3
27.11.2018
Medication
0
3
16.04.2019
Medication
0
3
15.04.2020
Medication
0
3
15.04.2020
Medication
0
3
15.04.2020
Medication
0
3
24.04.2020
Medication
0
3
12.10.2020
Medication
0
3
12.10.2020
Medication
0
3
20.11.2020
Medication
0
3
20.11.2020
Medication X
1
Now I would like to create a new variable, which counts the number of days before and after this claim, i.e. counting number of days backwards and forward from this event (newuse=1) for each patient_ID. How can I do this / which command do I have to apply?
I would be very happy for your help, thank you in advance.
... View more