Hi San, If I understand your question correctly, you want startdate = fill date and enddate = fillthrudate when rx_flag = 1 otherwise startdate = filldate. Try the solution below: data patientrx;
set filldate ;
by patient_id;
if rx_flag = 1 then
do ;
startdate = filldate;
enddate = filldatethru;
end;
else; do;
startdate = filldate;
end;
format startdate enddate mmddyy9.;
run;
... View more