Hi. I'm using SAS 9.4 and have a programming question (I'm also quite new to SAS). I want to "flag" all numbers from 4 to the first 0 in the diff_brunst variable by creating ones in the length variable, how do I do that? This is the code I have been trying. data c;
set b;
if diff_brunst = 4 then do length = 1 until (diff_brunst = 0);
end;
else length = 0;
run; Output (form a huge dataset). In the parentheses is what I want to achieve. Diff_brunst Length 0 0 0 0 0 0 0 0 0 0 2 0 3 0 4 1 (1) 5 0(1) 6 0(1) -5 0(1) 0 0(1) 0 0 0 0 0 0
... View more