This is the dataset I have
ID Status
1 A
1 A
1 Z
1 Z
1 A
1 Z
2 A
2 A
2 Z
2 Z
If status for any particular ID changes from Z to A, I want to update its value as A in all previous observations of that ID
So this is what i want after processing
1 A
1 A
1 A
1 A
1 A
1 Z
2 A
2 A
2 Z
2 Z
I tried this
data c;
set b;
by id;
if status = 'A' and lag(status) = 'Z' then lag(status)='A';
run;
But I get a dataset C with 0 observations. My original dataset B can have thousands of IDs and for some of them status may change from Z to A, so for all such IDs, I want to update status from Z to A as shown above
... View more