Hey sas_grad,
Here is a different solution to the problem.
data dy;
infile datalines dlm=',' missover;
input x y cnt;
datalines;
20, 100, 0
20, 100, 0
20, 100, 1
20, 100, 0
20, 100, 1
20, 100, 1
20, 100, 1
20, 100, 0
21, 101, 1
21, 101, 1
21, 101, 1
21, 101, 0
21, 101, 1
21, 101, 1
21, 101, 1
21, 101, 0
22, 102, 1
22, 102, 1
22, 102, 1
22, 102, 1
22, 102, 1
22, 102, 1
22, 102, 1
22, 102, 0
;
run;
data dy;
set dy;
by notsorted x y cnt;
retain count 0;
if first.cnt then count=_n_;
run;
proc sql;
create table final as
select a.x, a.y, a.cnt,b.count
from dy a
,( select x, y, cnt, count , count(count) as xx
from dy
group by x,y,cnt,count
having count(count) >= 3
) b
where a.count=b.count;
quit;
proc print;run;
Thanks!!!