Hi Experts,
I have a dataset like below
DATA survey;
INPUT id r1 r2 r3 r4 r5;
DATALINES;
1 1 0 0 1 1
2 1 0 1 1 1
3 1 . 0 . 1
4 1 1 0 1 1
5 0 1 . . 1
6 1 0 0 0 0
7 1 0 . 0 1
8 1 1 0 1 1
9 1 0 1 0 1
;
I have to generate 2 new variables A=the variable name for the last observation of 0; B = the variable name for the first observation of 1 after the last 0. For example, the 6th row: A=r5, B=''; the 9th row: A=r4, B=r5
Is there any idea how I can start? Thank you very much!