Well this may not be the fastest way but it will solve ur problem. Create a new variable in have Dataset. data have; n = _n_; /* If obs number is present then rename it to n else create a new variable */ input id V1 V2; datalines; 1 2 2.1 1 0 2.9 1 2 3.1 2 4 1.7 2 0 4.5 2 0 0.5 2 5 2.8 ; data want2(keep = n); set have; n = _n_ ; if v1 = 0 then do; output ; n = n - 1 ; output; end; run; proc sort data = want2 nodupkey; by n; run; data want3; merge have(in= x) want2(in= y); by n; if x and y; drop n; run;
... View more