Hello,
This is the data I have:
id | study_strt | study_end | drugname | drugtype | rx_date | days_sply | drug_start | rx_end |
1 | 2008-09-26 | 2010-09-26 | DrugA | 2 | 2008-10-13 | 30 | 17 | 2008-11-12 |
1 | 2008-09-26 | 2010-09-26 | DrugA | 2 | 2008-10-23 | 30 | 27 | 2008-11-22 |
2 | 2012-08-23 | 2014-08-23 | DrugB | 1 | 2012-08-25 | 45 | 2 | 2012-10-09 |
2 | 2012-08-23 | 2014-08-23 | DrugA | 2 | 2012-08-25 | 45 | 2 | 2012-10-09 |
Data I want would look like this:
id | study_strt | study_end | drugname | drugtype | rx_date | days_sply | drug_start | rx_end | discontinue |
1 | 2008-09-26 | 2010-09-26 | DrugA | 2 | 2008-10-13 | 30 | 17 | 2008-11-12 | 0 |
1 | 2008-09-26 | 2010-09-26 | DrugA | 2 | 2008-10-23 | 30 | 27 | 2008-11-22 | 0 |
2 | 2012-08-23 | 2014-08-23 | DrugB | 1 | 2012-08-25 | 45 | 2 | 2012-10-09 | 0 |
2 | 2012-08-23 | 2014-08-23 | DrugA | 2 | 2012-08-25 | 45 | 2 | 2012-10-09 | 1 |
Ideally I would like to keep my data in long form while identifying different medication treatment patterns. Medication discontinuation is defined as a gap of 30 days or more within the study period where there is no record of prescription. Any tips on how I can create an dichotomous variable called discontinue, where 0 = no discontinuation and 1 = discontinuation.
rx_date = date prescription is filled
drug_start = day in study period in which prescription was filled
Many thanks in advance!
Please state explicitly the rule(s) involved in creating that dichotomous variable Discontinue.
It helps greatly to be consistent in code and data description. Your "have" data does not have a variable named "drugname" but that is used in your code.
Examples are nice but do not necessarily provide rules to handle cases other than what is shown.
Are you assuming the rx_date is the date a prescription is filled? What exactly does "drug_start" represent?
I am not clear exactly what you mean by " modify to create dichotomous indicator variable (0/1) rather than output dataset?".
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.