I am facing a problem with medications data.I am trying to create a dataset that has all the days upto one year and depending upon the start and stop dates of medication it will have a value of 1 or 0.
eg. day0 day1, day2--- day365.
When I use the array to create these variables , I am facing problem while filling the days in there. If the medication was continued for 12 days then day0 -day12 will have a value of 1 and all others variables will have the value 0 for all patients and so on.
Can anyone please help me as to how can this be programmed.Also some medications are stoped and then started again.
Thank you for your time.
Suggest you reply to your post and list specific INPUT (representative) and OUTPUT (desired) data/variable observation values you would like to achieve. Also, share any SAS code you have tried. This info will be most helpful with getting useful and timely feedback.
I was able to create the dataset with all days from 0-365 for each medicine and assign a value of 1 or 0 depending upon if the patient was taking the medication on a certain day.
If anyone needs help with similar code ill post the code for it.
Definitely post the code you ended up with. It's always useful to other visitors and subscribers for examples on how to accomplish a task in SAS, and it may provide an opportunity for further improvement and code efficiency. Reply to your post and COPY/PASTE the code directly in your message body.
code for previous question:
The dataset can have multiple start days if patient was discontinued and then started again.I first transposed the data to get all start and stop dates in sequence.
proc transpose data=ds_name prefix= str out= str_dt(drop=_NAME_);
similar for stop date and continued variable.
str= start date.
procdt=procedure date as the day 0 is calculated from procedure date.
cont1 &cont2 = export variable that says medicine was continued.
If there is no stop date then the end date is the last follow-up date.Here I am using 30 day follow-up date.
if str1 ne . and str1 < PROCDT then str1=PROCDT;
if str1 ne . and stp1 ne . then days1=(stp1-str1);
if str2 ne . and stp2 ne . then days2=(stp2-str2);
if str1 ne . and stp1 = . and cnt1 = 1 then days1=(FU30DT-str1);
if str2 ne . and stp2 = . and cnt2 = 1 then days2=(FU30DT-str2);
array daysarray(41) day0-day40;
array dates1(*) str1 - str2 ;
array dys(*) days1 - days2 ;
do ii=1 to 41;
do ii=1 to 41;
do i=1 to dim(dates1) while (dates1(i) ne .) ;
if dates1(i) <= str1 + ii -1 <= dates1(i)+ dys(i)-1 then
if str1 > PROCDT then do;
do j=1 to (str1-PROCDT);
first initializing all the days to 0. then depending on the condition they will be set to 1.If in any case the first start date was after procedure then days from procedure to that start will be reset to zero.
Using the output I calculated if the patient was taking the medication at discharge . also, if he was taking medication for 50% of days between discharge and follow-up then follow-up medication is yes.
My code is indented but when i copy paste it here I am unable to indent it so please understand.
I hope this helps.
If anyone thinks of any corrections please advise. Yours comments and suggestions are welcome.