help with array

Reply
N/A
Posts: 0

help with array

Hi All,

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.

Regards,
April
Super Contributor
Super Contributor
Posts: 3,174

Re: help with array

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.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: help with array

Hi,

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.

Thanks,
Regards
April
Super Contributor
Super Contributor
Posts: 3,174

Re: help with array

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.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: help with array

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.

code:
proc transpose data=ds_name prefix= str out= str_dt(drop=_NAME_);
var STARTDT;
by patientid;
run;
similar for stop date and continued variable.
str= start date.
stp= stopdate.
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.
data asp_days;
set test;
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;
daysarray(ii)=0;
end;
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
daysarray(ii)=1;
end;
end;
if str1 > PROCDT then do;
do j=1 to (str1-PROCDT);
daysarray(j)=0;
end;
end;
run;
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.

Regards,
April.
Ask a Question
Discussion stats
  • 4 replies
  • 436 views
  • 0 likes
  • 2 in conversation