I have to ultimately code for medication discontinuation, intensification, and switching, but I'm stuck on even how to start this...
Here is a snippet of my dataset:
pat_id | start_date | end_date | drug |
43 | 2-Dec-03 | 1-Mar-04 | 1 |
43 | 3-Feb-04 | 3-May-03 | 1 |
43 | 11-Jun-04 | 9-Sep-04 | 1 |
43 | 16-Sep-04 | 15-Dec-04 | 1 |
43 | 4-Dec-02 | 4-Mar-03 | 2 |
51 | 4-Oct-10 | 2-Jan-11 | 1 |
51 | 20-Nov-02 | 18-Feb-03 | 1 |
51 | 1-Feb-03 | 2-May-03 | 2 |
51 | 17-Dec-02 | 24-Dec-02 | 2 |
51 | 31-Jan-03 | 1-May-03 | 3 |
51 | 4-Oct-10 | 2-Jan-11 | 3 |
My data goes for 9 years and the patients can be on a potential of 11 drugs (however, I don't beleive anyone reaches that amount in the data). I've already taken those patients who had a medication days_supply <30 (since I don't find that to be clinically relevent). Now I would like to start coding for discontinuation (i'm thinking another column that will be binary), based on these rules: no evidence of a drug for >=180 consecutive days. so, for example, drug 2 is discontinued in the first patient starting on 3-4-2003.
any ideas on how to go about this?
thanks!
-
It depends on which date you assume for the calculation of drug discontinuation.
data have;
input pat_id start_date :anydtdte. end_date :anydtdte. drug;
format start_date end_date yymmdd.;
datalines;
43 2-Dec-03 1-Mar-04 1
43 3-Feb-04 3-May-03 1
43 11-Jun-04 9-Sep-04 1
43 16-Sep-04 15-Dec-04 1
43 4-Dec-02 4-Mar-03 2
51 4-Oct-10 2-Jan-11 1
51 20-Nov-02 18-Feb-03 1
51 1-Feb-03 2-May-03 2
51 17-Dec-02 24-Dec-02 2
51 31-Jan-03 1-May-03 3
51 4-Oct-10 2-Jan-11 3
;
/* Effective date for discontinuation calculation */
%let currDate=today();
/* Or */
%let currDate='01JAN2005'd;
proc sql;
create table have1 as
select *, intck("DAY", max(end_date), &currDate.) > 180 as discont
from have
group by pat_id, drug;
select * from have1;
quit;
PG
Hi PGstats,
Thank you for your reply, I have to questions in response:
1.) How did you know to choose 1/1/2005 as the current date? is this arbitrary?
2.) The code worked, however I'm needing it to do more...if I arrange the medication by patient in accordance to when they start their medicine (example below), there's gaps in medication use that aren't being captured with this code. For example if you look at patient 1, they are showing no medicine from 4-mar-2003 to 2-dec-2003, which is a gap in all meds of 273 days. how do I account for this? thanks much!
pat_id | start_date | end_date | drug |
43 | 18-nov-02 | 16-feb-03 | 1 |
43 | 4-dec-02 | 4-mar-03 | 2 |
43 | 2-dec-03 | 1-mar-04 | 1 |
43 | 3-feb-04 | 3-may-04 | 1 |
43 | 11-jun-04 | 9-sep-04 | 1 |
51 | 20-nov-02 | 18-feb-03 | 1 |
51 | 17-dec-02 | 24-dec-02 | 1 |
51 | 31-jan-03 | 1-may-03 | 2 |
51 | 1-feb-03 | 2-may-03 | 2 |
51 | 4-oct-10 | 2-jan-11 | 3 |
51 | 4-oct-10 | 2-Jan-11 | 3 |
Take some time to define how you want your output data to look like and all potential edge cases. It's much easier to get where you want to go and much easier to make suggestions. The way your question is currently formulated we'll have to guess at outputs, as well as it's restricted to people who have dealt with this exact scenario. If you phrase it in terms of a programming problem you'll get better responses.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.