Dear Statalist
I am working with a data set containing patients (patid) with repeat prescriptions (RXnumber) with the prescription issue date (RXdate) and am trying to generate a treatment exposure period.
When repeat prescriptions are within 60 days of each other (Repeat <60) then they fall within the same treatment episode (TE).
One-off prescriptions [gaps of more than 60 days between prescriptions (Repeat > 60)] are assumed to have an exposure period of 60 days and form their own TE.
I need to use the subsequent observation in the variable Repeat to set the exposure period for the one-off prescriptions (60 days).
This is because I cannot distinguish one-off prescriptions from the first prescription of a treatment episode (with more than one prescription).
I will then be using the median Repeat value in a specific TE with more than one prescription (at patient level). This will be the exposure period for the last prescription in a TE with more than one prescription.
I would be extremely grateful for any suggestions.
Please let me know if you require any further clarification.
Many thanks
Debabrata
I am working with a data set containing patients (patid) with repeat prescriptions (RXnumber) with the prescription issue date (RXdate) and am trying to generate a treatment exposure period.
When repeat prescriptions are within 60 days of each other (Repeat <60) then they fall within the same treatment episode (TE).
One-off prescriptions [gaps of more than 60 days between prescriptions (Repeat > 60)] are assumed to have an exposure period of 60 days and form their own TE.
I need to use the subsequent observation in the variable Repeat to set the exposure period for the one-off prescriptions (60 days).
This is because I cannot distinguish one-off prescriptions from the first prescription of a treatment episode (with more than one prescription).
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long patid int RXnumber float(RXdate Repeat TE) 1 1 18682 0 1 1 2 18711 29 1 1 3 18744 33 1 1 4 18774 30 1 1 5 18806 32 1 1 6 18821 15 1 1 7 18849 28 1 1 8 18876 27 1 1 9 18903 27 1 2 1 17365 0 1 2 2 17847 482 2 2 3 17870 23 2 3 1 19124 0 1 3 2 19883 759 2 3 3 20135 252 3 3 4 20170 35 3 3 5 20186 16 3 end format %td RXdate
I would be extremely grateful for any suggestions.
Please let me know if you require any further clarification.
Many thanks
Debabrata
Comment