From: Ita Cirovic Donev on 26 May 2010 05:35 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 26 May 2010 07:49 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 27 May 2010 02:39 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
|
Pages: 1 Prev: Histogram with gplot Next: Proc printto print statement not working in Enterprise Guide |