I'm not 100% this is what you are looking for but here is a solution for how I translated your question: data have; infile cards dsd ; input a$ b$ c$ d$; cards; ,one,, ,two,, ACE,,, ,two,, ,three,, ,four,, ,five,, ,six,, ,seven,, ,eight,, ,nine,, ,ten,, ,eleven,, ,twelve,, ,thirteen,, ,fourteen,, ,fifteen,, ,sixteen,, ACE,,, ,two,, ,three,, ; run; data want(drop=count ace_count); set have; count + 1; if a = 'ACE' then count = 1; retain ace_count; if a = 'ACE' then ace_count = 1; if count > 15 then ace_count = .; if 1 <= count <= 15 and ace_count = 1 then output; run;
... View more