How to get distinct fruits where indicator =only B and make sure that fruit listed is not coded on any "A" Indicator column.
I tried this but obviously its not working. EDITED:
example;
fruits | Indicator |
---|---|
apple | A |
Strawberry | B |
apple | B |
Strawberry | B |
Orange | A |
Orange | B |
Mango | B |
Banana | A |
Peach | B |
Cherry | A |
Strawberry | B |
Output that I want:
fruits | Indicator |
---|---|
Mango | B |
Peach | B |
strawberry | B |
Note: even though Apple and Orange has A and B, we do not want those on the output since both also have indicator A. We want fruits that only has B.
Code that I used: proc sql; create table unique as select distinct fruits, indicator from example where indicator='b' and fruits in(select distinct fruits from example where indicator='b'); quit;
but this gets:
fruits | Indicator |
---|---|
apple | B |
orange | B |
mango | B |
peach | B |
strawberry | B |
I need to add another step ..i.e. if fruit = both A and B indicator then do not get that value.