Try this
data have;
input patient_id week condition @@;
datalines;
1 1 0
1 2 1
1 3 3
2 2 2
2 5 1
3 1 3
4 2 0
4 3 1
4 4 1
4 5 2
;
run;
data want(drop = flag);
set have;
by patient_id;
if first.patient_id then flag = 0;
if flag = 0 then output;
if condition = 1 then flag = 1;
retain flag;
run;
Result:
patient_id week condition
1 1 0
1 2 1
2 2 2
2 5 1
3 1 3
4 2 0
4 3 1