Hello,
has anyone had an issue with the code:
if firste>. then do p=max(_n_-2,1,p) to min(_n_+2,nobs); set have point=p nobs=nobs;
I am having issue with the record ID E.
data have; input ID $ AGE RATE TYPE $ FIRSTE; datalines ; A 14.1 -4.19560471 N . A 15.1 -4.186550471 E -4.186550471 A 15.3 -4.041576561 E . A 15.6 -3.984641999 E . A 15.8 -4.079763059 E . A 16.2 -4.198425079 E . B 6.2 -1.118603619 N . B 12.25 -3.251832999 N . B 12.4 -3.158418124 N . B 14.8 -3.739770279 N . B 19.1 -3.980687937 E -3.980687937 B 19.6 -3.901730725 E . C 4.3 2.1339735869 N . C 5.4 2.1571201461 N . C 5.6 2.1571201461 E 2.1571201461 C 6.1 2.6609995525 E . C 6.7 2.1939735869 E . C 7.1 2.6991891929 E . D 2.4 -0.35998761 N . D 2.6 -0.650544267 N . D 3.2 -0.817670577 E -0.817670577 D 3.7 -0.659657975 E . D 4.2 -0.370159291 E . E 15.6 -3.679862707 N . E 16.4 -3.248757219 E -3.248757219 E 16.9 -3.128994865 E . E 17.4 -2.892552007 E . E 17.9 -2.741253675 E . E 18.4 -2.591966458 E . E 19.3 -2.42630517 E . ; run;
data want; set have; if firste>. then do p=max(_n_-2,1,p) to min(_n_+2,nobs); set have point=p nobs=nobs; output; end; run;
When I run the code on a subset of my dataset , I get the right records.
E 16.4 -3.248757219 E -3.248757219 E 16.9 -3.128994865 E . E 17.4 -2.892552007 E . E 17.9 -2.741253675 E .
But when I run the code on the whole set , for ID E I get one extra observation
E 16.4 -3.248757219 E -3.248757219 E 16.9 -3.128994865 E . E 17.4 -2.892552007 E . E 17.9 -2.741253675 E .
E 19.3 -2.42630517 E .
I am not able to figure out why this extra row gets added. It is only happening for this one record when the full dataset is used (1000 records)
Anyone has a suggestion?
Thanks
... View more