Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: interval variable to rank variable


From   Alexey Bessudnov <[email protected]>
To   [email protected]
Subject   Re: st: interval variable to rank variable
Date   Fri, 17 Apr 2009 23:14:54 +0100

Austin, Eva - many thanks for both solutions.

Alexey


Austin Nichols wrote:
See
http://www.stata.com/support/faqs/stat/pcrank.html
and try:

clear
input x wanted
 1   1
 1   1
 15  2
 15  2
 47  3
 47  3
end
g long obs=_n
sort x
g long noskip=sum(x!=x[_n-1]) if x<.
sort obs
list, noo clean

On Fri, Apr 17, 2009 at 4:41 PM, Alexey Bessudnov
<[email protected]> wrote:
Dear all,

I have an interval variable v1 with values 1,1,15,15, 47, 47, etc. and I
want to recode it into a rank variable v2 so that 1=1, 15=2, 47=3, etc. Is
there any simple way to do this automatically? I have tried -egen rank,
track-, but it returns v3.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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