@polingjw: Here is another way, taking advantage of proc sql's automatic re-merging of the summary statistics:
[pre]
/* test data by polingjw */
data test;
input phyid flag $;
datalines;
1001 C
1002 P
1003 C
1003 P
1004 C
1004 P
;
run;
proc sql;
create table test2 as
select phyid, flag, sum(flag="C") as c, sum(flag="P") as p
from test
group by phyid;
/* print out an obs if the id has only C or P;
the flag="P" obs if the id has both */
select * from test2
where (c and not p) or (not c and p) or (c and p and flag="P");
/* on lst
phyid flag c p
--------------------------------------
1001 C 1 0
1002 P 0 1
1003 P 1 1
1004 P 1 1
*/
quit;
[/pre]