not sure if this is what OP asked, but if it is, I really like the approach. To make more dynamic, here is Hash alternative: data have; do i = 1 to 10000; field1 = int(20*ranuni(3)); *assume that field1 is not greater than, say, 19; output; end; run; data want; if _n_=1 then do; declare hash h(); h.definekey('field1'); h.definedata('zcnt'); h.definedone(); call missing(zcnt); end; set have; rc=h.find(); if rc=0 then do; zcnt+1; h.replace(); end; else do; zcnt=1; h.replace(); end; run;
... View more