Hi, I have the following dataset, Col1/Col2/Co3: A/1/0; A/3/1; A/5/0; A/8/0; B/1/0; B/2/1; B/3/0; B/4/1; B/5/0; Col1/2/3 are strings, numeric and boolean(1 for true and 0 for false). Data are ordered by Col1 and 2. Now I would like to add an extra column (Col4), beginning with 1, based on the following rules: If Col3=1 then Col4=1 else Col4 is set to the Col3 value of the previous Col2 for the same Col1 plus+1. Hence, Col4 is a counter and Col3 serves as an indicator to reset the counter. The new dataset looks like this: Col1/Col2/Col3/Col4: A/1/0/1; A/3/1/1; A/5/0/2; A/8/0/3; B/1/0/1; B/2/1/1; B/3/0/2; B/4/1/1; B/5/0/2; I am newbie to SAS so appreciate if anyone can help me out wth this. Many thank in advance.
... View more