FWIW, Hash() is able to offer a true dynamic one-step splitting solution: data have; infile cards truncover; input (id var1 var2 var3) (:$); cards; 1 a b c 1 a b c 1 a b c 2 a b c 3 a b c 1 a b c ; data _null_; if _n_=1 then do; if 0 then set have; declare hash h(multidata:'y', ordered:'a'); h.definekey('id'); h.definedata('id','var1','var2','var3'); h.definedone(); end; do while (1); set have end=last; n+1; if n <=2 then rc=h.replace(); else if id='1' then do; c+1; rc=h.output(dataset:'NO'||left(c)); rc=h.clear(); rc=h.replace(); n=1; if last then do; c+1; rc=h.output(dataset:'NO'||left(c));end; leave; end; else rc=h.replace(); end; run; Group size is 2, and if you need a group number for downstrem process, it can be easily added. Haikuo
... View more