I tested it again and am getting the desired result. I did spell flag differently from you. Run each subquerry alone and check.
data one;
input terrid $ phys $ flag $;
cards;
123 aaa Y
123 bbb n
123 ccc n
456 hhh n
456 jjj n
456 kkk Y
456 lll Y
run;
proc sql;
create table two as select b.* from one b where b.terrid in
(select a.terrid from (select terrid, count(flag) as cf from one
where flag = 'Y' group by terrid) a where a.cf > 1);
quit;
14:23 Monday, August 24, 2009
Obs terrid phys flag
1 456 hhh n
2 456 jjj n
3 456 kkk Y
4 456 lll Y