BookmarkSubscribeRSS Feed
macro_2349
Calcite | Level 5

Hello,
This is the data I have:

 

idstudy_strtstudy_enddrugnamedrugtyperx_datedays_splydrug_startrx_end
12008-09-262010-09-26DrugA22008-10-1330172008-11-12
12008-09-262010-09-26DrugA22008-10-2330272008-11-22
22012-08-232014-08-23DrugB12012-08-254522012-10-09
22012-08-232014-08-23DrugA22012-08-254522012-10-09


Data I want would look like this:

idstudy_strtstudy_enddrugnamedrugtyperx_datedays_splydrug_startrx_enddiscontinue
12008-09-262010-09-26DrugA22008-10-1330172008-11-120
12008-09-262010-09-26DrugA22008-10-2330272008-11-220
22012-08-232014-08-23DrugB12012-08-254522012-10-090
22012-08-232014-08-23DrugA22012-08-254522012-10-091


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!




 

2 REPLIES 2
ballardw
Super User

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?".

 

macro_2349
Calcite | Level 5
Thank you. I have modified my original post to answer your queries. Please let me know if you require further clarification.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1147 views
  • 0 likes
  • 2 in conversation