From: Ita Cirovic Donev on
I have a table like

Account Group Rating
1111 A NR
1111 B NR
1112 B 4E
1124 B NR
1322 A NR
1222 A NR
1222 B 5E
1222 P NR
etc.

I would like to select unique accounts so that if there are more than
one group per account take that Rating where the group is B.
If there is no B group per account (like 1322) then thake the one that
exists solely.

how would I proceed to get the result?

thanks
From: Amar Mundankar on
On May 26, 2:35 pm, Ita Cirovic Donev <itacdo...(a)gmail.com> wrote:
> I have a table like
>
> Account Group  Rating
> 1111         A        NR
> 1111         B        NR
> 1112         B        4E
> 1124         B        NR
> 1322         A        NR
> 1222         A        NR
> 1222         B        5E
> 1222         P        NR
> etc.
>
> I would like to select unique accounts so that if there are more than
> one group per account take that Rating where the group is B.
> If there is no B group per account (like 1322) then thake the one that
> exists solely.
>
> how would I proceed to get the result?
>
> thanks

Hi Ita Cirovic Donev,
Try the following:
data have;
input Account Group $ Rating $;
cards;
1111 A NR
1111 B NR
1112 B 4E
1124 B NR
1322 A NR
1222 A NR
1222 B 5E
1222 P NR
;
proc sort data = have out = have_sorted;
by account group;
run;
data want;
set have_sorted;
by Account Group;
if Group = 'B' or (first.account = last.account);
run;

Thanks and Regards,
Amar Mundankar.
From: Barry Schwarz on
On Wed, 26 May 2010 04:49:26 -0700 (PDT), Amar Mundankar
<amarmundankar(a)gmail.com> wrote:

>On May 26, 2:35�pm, Ita Cirovic Donev <itacdo...(a)gmail.com> wrote:
>> I have a table like
>>
>> Account Group �Rating
>> 1111 � � � � A � � � �NR
>> 1111 � � � � B � � � �NR
>> 1112 � � � � B � � � �4E
>> 1124 � � � � B � � � �NR
>> 1322 � � � � A � � � �NR
>> 1222 � � � � A � � � �NR
>> 1222 � � � � B � � � �5E
>> 1222 � � � � P � � � �NR
>> etc.
>>
>> I would like to select unique accounts so that if there are more than
>> one group per account take that Rating where the group is B.
>> If there is no B group per account (like 1322) then thake the one that
>> exists solely.
>>
>> how would I proceed to get the result?
>>
>> thanks
>
>Hi Ita Cirovic Donev,
>Try the following:
>data have;
> input Account Group $ Rating $;
> cards;
>1111 A NR
>1111 B NR
>1112 B 4E
>1124 B NR
>1322 A NR
>1222 A NR
>1222 B 5E
>1222 P NR
>;
>proc sort data = have out = have_sorted;
> by account group;
>run;
>data want;
> set have_sorted;
> by Account Group;
> if Group = 'B' or (first.account = last.account);
>run;

Better to use (first.account & last.account to deal with the case
where there are mote than three observations per account or the middle
one is not group B

--
Remove del for email