Date: Thu, 7 Dec 2006 09:24:42 -0500
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: sorting problem
On Thu, 7 Dec 2006 02:08:43 -0800, gopilth@YAHOO.COM wrote:
>Hi,
>I have a problem sorting data sets
>data set A:
>id score1 score2
>1 10 11
>1 10 20
>2 18 17
>3 11 13
>3 12 13
>4 10 19
>5 17 20
>5 21 20
>
>out put file:
>id score1 score2
>1 10 20
>2 18 17
>3 12 13
>4 10 19
>5 21 20
>
>output should not have repeates of id's and should have highest score
>(both in score1 and score2).
>thanks in advance
>gopi.
Your example is a special case. Whenever there are multiple observations for
some ID value, either SCORE1 or SCORE2 is invariant within the group (eg,for
ID=3, SCORE2=13 throughout, so that the choice can be made on the basis of
SCORE1 values alone).
Suppose you have
ID Score1 Score 2
6 1 2
6 2 1
Should the output include the first observation, the second observation, or
a composite (with SCORE1=2 and SCORE2=2). Or is there some other rule, such
as picking the observation with the largest sum of SCORE1 and SCORE2? Or are
you sure that the special property described above will always hold true in
your data?
|