Hi @v307086 , Please try the below code : data test1; set test; retain date1; if not missing(date) then date1= date ; else date1 =date1; temp_dt = lag2(date1); if lag(response) = 'NE' then date1 = temp_dt; drop temp_dt date ; rename date1 = date; run; I am getting the same output as you requested using this code.
... View more