我正在使用数组编写SAS代码以标记住院病人的开始日期或结束日期何时超出训练间隔。另外,当住院的开始或结束日期不在训练间隔内时,我想返回训练的开始日期或结束日期。
DATA InptBHEnc_All19 (keep= start1 end1 start2 end2 start3 end3 `enter code here`start4 end4 start5 end5 begin_date end_date OverlapsBCTStart NewEnd_Date OverlapsBCTEnd newbegin_date);
SET test;
array start{*} start:;
array stop{*} end:;
do i=1 to dim(START);
IF (Begin_Date < start{i} LE End_Date) AND (End_Date =< stop{i}) THEN OverlapsBCTStart=1;
IF OverlapsBCTStart=1 and start(i)<= end_date <= stop(i) THEN DO;
NewBegin_date= max(of start(*));
/*Flag records where begin date is between the start and end of training, and the End_date is outside of training interval*/
IF (start(i) < Begin_Date) AND (Begin_Date LE stop(i) < End_Date)THEN OverlapsBCTEnd=1;
IF OverlapsBCTEnd=1 AND start(i) <= begin_date <= stop(i) THEN NewEnd_Date= min(of stop(*));
format newbegin_date date9.;
end;end;
drop i;
RUN;