Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: A belated comment on -egen, rank()-


From   "Scott Merryman" <smerryman@kc.rr.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: A belated comment on -egen, rank()-
Date   Mon, 2 Oct 2006 14:42:04 -0500

I guess this would work for those who like easy and direct solutions.

Welcome back Nick.

Scott


> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
> Sent: Sunday, October 01, 2006 12:45 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: A belated comment on -egen, rank()-
> 
> In a recent thread, Nikolaos A. Patsopoulos wanted ranks
> like this:
> 
>       +-------------------+
>       |  v1    v2    rank |
>       |-------------------|
>    1. | aaa   374       1 |
>    2. | bbb   213     2.5 |
>    3. | ccc   204       4 |
>    4. | gvf   193       5 |
>    5. | gfd   170       6 |
>       |-------------------|
>    6. | gfd   166       7 |
>    7. | abc   213     2.5 |
>       +-------------------+
> 
> In addition to other solutions, note that
> 
> egen rank = rank(-v2)
> 
> would work. The key detail here is that the
> -egen- function takes an expression, which
> can include the negation operator to flip
> ranks around.
> 
> Nick
> n.j.cox@durham.ac.uk
> 


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index