Every time I think I know what's going on, suddenly there's another layer of complications.
proc sort data=have(keep=key1 key2); by key1 key2; run;data want; do count=1 by 1 until(last.key2); set have; by key1 key2; end; run;
proc sort data=have(keep=key1 key2); by key1 key2; run;
data want; do count=1 by 1 until(last.key2); set have; by key1 key2; end; run;