Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Ranking timed data


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Ranking timed data
Date   Thu, 14 Apr 2005 12:08:27 +0100

I don't know why you think -recode- is relevant 
here. Typing 

. search rank

will point you towards the -egen- function -rank()-. 

. egen rank = rank(var), by(time) field 

may well be adequate for your purpose. You might need to 
think about what you want if any ties occur. 

Nick 
n.j.cox@durham.ac.uk 

Sascha Robert
 
> I applogize for this newbie question in advance.
> My data looking like this
> 
> time    id    var
> 1        1    19.5
> 1        2    20.7
> 1        3    15.0
> 2        1    16.5
> 2        2    21.7
> 2        3    17.0
> ...
> 
> Now I would like to generate a variable 'rank' for each value 
> of 'time' 
> representing the ordinal number of th value 'var':
> 
> time    id    var    rank
> 1        1    19.5    2
> 1        2    20.7    1
> 1        3    15.0    3
> 2        1    16.5    3
> 2        2    21.7    1
> 2        3    17.0    2
> ...
> 
> . recode does not seem to work, because 'var' changes to a 
> great extent over time.

*
*   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