Hey @Nici ,
I hope this works for you:
data want(drop=x y);
set have;
x = id;
if anncmt>. then
do p=max(_n_-3,1) to min(_n_+3,nobs);
set have point=p nobs=nobs;
if x=id then
output;
else
do;
y = cat("Missing obs for the id: ",x);
put y;
end;
end;
run;
I get the output:
1 19990206 0.02
1 19990207 0.04
1 19990208 0.01
1 19990209 0.02 19990209
1 19990210 0.01
1 19990211 0.02
1 19990212 0.03
2 19990206 0.02
2 19990207 0.04
2 19990208 0.01
2 19990209 0.02 19990209
2 19990210 0.01
2 19990211 0.02
3 19990206 0.02
3 19990207 0.04
3 19990208 0.01
3 19990209 0.02 19990209
3 19990210 0.01
3 19990211 0.02
3 19990212 0.03
In the log one Missing obs for the id: 2 is added you could also output these to another table.
If you have any question about the coding please let me know.
Best regards
Criptic
... View more