If the data are sorted by acct_no/cyc_no, then the programming is easy with a DATA step. All you need to determine is whether the cyc_no value for the current qualifying obs is no more than two greater than the second prior qualifying obs (and has the same acct_no). By "qualifying" I mean obs with a positive payment.
If this is true then:
data want;
set have;
by acct_no;
flag=0;
if fix_paymt>0 then do;
if lag2(acct_no)=acct_no and lag2(cyc_no)>=cyc_no-2 then flag=1;
end;
run;
... View more