Creating a sequence variable by subgroup

data indiv4;
set indiv3;
if N_entry > 9;
run;
proc sort;by subgroup;
run;

data indiv5;
retain sequence;
set indiv4;
by subgroup;
if first.subgroup then sequence=0;
sequence=sequence+1;
run;

Leave a Reply