LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2003, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 8 Dec 2003 11:45:00 -0500
Reply-To:     "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Subject:      Re: how to define a new rank ?
Comments: To: benabbou@UOTTAWA.CA

Hi, Nabil,

I would recommend using proc rank: it has options to deal with ties and the like. An example is in the below:

Cheers, Chang

<sasl:code> data one; input x y; cards; 1 40 1 30 1 30 2 10 2 10 3 20 3 10 3 30 ; run; proc rank data=one out=two ties=low descending; by x; var y; ranks r; run; proc print data=two; run; /* Obs x y r

1 1 40 1 2 1 30 2 3 1 30 2 4 2 10 1 5 2 10 1 6 3 20 2 7 3 10 3 8 3 30 1 */ </sasl:code>

On Mon, 8 Dec 2003 11:23:26 -0500, Nabil Benabbou <benabbou@UOTTAWA.CA> wrote:

>Hello everyone > >I want to create a new variable `r' in the following data (here is an >example) > >Data data1; >input x y; >cards; >1 40 >1 30 >1 30 >2 10 >2 10 >3 20 >3 10 >3 30 >; run; > >The treatment would be > >proc sort data=data1; by x; > >the rank would be defined by the second variable y > >The output will be : > >x y r >1 40 1 >1 30 2 >1 30 2 >2 10 1 >2 10 1 >3 20 2 >3 10 3 >3 30 1 > >Thank very much for your help > > > >Nabil


Back to: Top of message | Previous page | Main SAS-L page