Determine the number of obs per studid in an intermediate step and then merge with the original dataset.
Note the use of the keep= option.
data have;
input studid marks;
cards;
1 24
1 24
1 24
2 24
2 24
3 24
;
run;
data int (keep=studid);
set have;
by studid;
if first.studid
then newvar = 1;
else newvar + 1;
if last.studid and newvar > 1;
run;
data want;
merge
have
int (in=a)
;
by studid;
if a and (first.studid or last.studid);
run;
... View more