|
Can I get comments on the following approach please? Many times when I need to isolate obs w/a maximum value in one var, and use a second var to break ties I'll do a couple of PROC SORTs, like so:
proc sort ;
by max_var tie_breaker descending ;
run ;
proc sort nodupkey ;
by max_var ;
run ;
On the theory that the first sort will bring all the high values of tie_breaker to the top of each max_var group, and the second one will ditch all but the first value in each group. This has panned out for me in spot-checks, but I don't know whether it should be true in principle. Do any of you?
Thanks!
-Roy
P.S. This isn't really the problem that Iris presented, but if it were, the code I would use is:
data one ;
infile cards ;
input plan I1 I2 I3 I4 I5 ;
overall_preference = sum(of I:) ;
disagreement = std(of I:) ;
cards;
1 5 0 0 5 5
2 3 3 3 3 3
3 3 4 2 4 2
4 4 1 2 3 5
5 2 3 4 5 5
6 0 0 0 0 1
7 1 1 1 1 1
;
run ;
proc sort ;
by overall_preference disagreement ;
run ;
proc print ;
proc sort nodupkey ;
by overall_preference ;
run ;
proc print ;
________________________________
From: SAS(r) Discussion on behalf of SAS L
Sent: Fri 6/10/2005 11:47 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Ranking
A little change...
data one ;
infile cards ;
input plan I1 I2 I3 I4 I5 ;
cards;
1 5 0 0 5 5
2 3 3 3 3 3
3 3 4 2 4 2
4 4 1 2 3 5
5 2 3 4 5 5
6 0 0 0 0 1
7 1 1 1 1 1
;
run ;
data two ;
set one ;
If ( sum(of I:) = 15 )and ( std(of I:) = 0.0000 ) ;
run ;
data three ;
set one ;
If ( sum(of I:) in:(5,10,15,20,25) )and ( std(of I:) = 0.0000 ) ;
run ;
proc print ;
run ;
toby dunn <tobydunn@HOTMAIL.COM> wrote:Iris,
data one ;
infile cards ;
input plan I1 I2 I3 I4 I5 ;
cards;
1 5 0 0 5 5
2 3 3 3 3 3
3 3 4 2 4 2
4 4 1 2 3 5
5 2 3 4 5 5
6 0 0 0 0 1
7 1 1 1 1 1
;
run ;
data two ;
set one ;
If ( sum(of I:) = 15 )and ( std(of I:) = 0.0000 ) ;
run ;
proc print ;
run ;
Toby Dunn
From: Iris Hui
Reply-To: Iris Hui
To: SAS-L@LISTSERV.UGA.EDU
Subject: Ranking
Date: Fri, 10 Jun 2005 14:06:37 -0400
Dear SAS-experts:
I am attempting to evaluate some redistricting plans. These plans are
evaluated by 5 indicators, each indicator ranges from 0 to 5, (0=the worst
and 5=the best).
My dataset is set up this way
Plan Indicator1 indicator2 indicator3 indicator4 indicator5
1 5 0 0 5 5
2 3 3 3 3 3
3 3 4 2 4 2
4 4 1 2 3 5
etc..
Assuming all these indicators carry the same weight, the simple method to
find out which plan is the best is to add up the scores for the five
indicators.
But the problem is I end up getting a lot of ties (as in my example, these 4
plans all have a total score of 15). I want to find a way to break the tie.
Essentially, for the plans with the same total score, I prefer plan that is
more 'balanced' (as in the 2nd case, 3 3 3 3 3) to the plan that is more
'extreme'. So in other words,
33333 (is preferred to) > 34242 > 41235 > 50055
Is there a way to write a program like this?
Let me thank you in advance for your help. =)
Iris
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|