Hi everyone.
I have a dataset in which I am trying to determine gaps between prescriptions and whether they are less than 90 days and therefore in the same "treatment course".
For example:
prescription gap (days)
30 (1st course of treatment)
45 (1st course of treatment)
23 (1st course of treatment)
89 (1st course of treatment)
150 (more than 90 days - new course - 2nd course of treatment)
34 (2nd course of treatment)
23 (2nd course of treatment)
300 (more than 90 days - 3rd course of treatment)
45 (3rd course of treatment)
and so on....
I have tried the following commands:
by patid: gen ct=1 if prsc_gap[_n+1]<=90
by patid: replace ct=2 if prsc_gap>90 & prsc_gap[_n-1]>90
but I know that this is probably the wrong way to go about this problem and am struggling to find an alternative.
Does anyone know how I could approach this?
Thanks a lot!
I have a dataset in which I am trying to determine gaps between prescriptions and whether they are less than 90 days and therefore in the same "treatment course".
For example:
prescription gap (days)
30 (1st course of treatment)
45 (1st course of treatment)
23 (1st course of treatment)
89 (1st course of treatment)
150 (more than 90 days - new course - 2nd course of treatment)
34 (2nd course of treatment)
23 (2nd course of treatment)
300 (more than 90 days - 3rd course of treatment)
45 (3rd course of treatment)
and so on....
I have tried the following commands:
by patid: gen ct=1 if prsc_gap[_n+1]<=90
by patid: replace ct=2 if prsc_gap>90 & prsc_gap[_n-1]>90
but I know that this is probably the wrong way to go about this problem and am struggling to find an alternative.
Does anyone know how I could approach this?
Thanks a lot!
Comment