Data have;
input id var1;
datalines;
1 54
1 60
1 .
1 .
1 .
1 .
1 .
2 100
2 .
2 .
2 200
2 .
2 .
;
Run;
data want;
set have;
by id;
retain v;
if first.id then do;n=0;v=.;end;
if not missing(var1) then do;n=0; v=var1;end;
n+1;
if n gt 4 then v=.;
run;
proc print;run;
... View more