Statalist


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

Re: st: Recode non-integers to positive integers


From   John Ataguba <[email protected]>
To   [email protected]
Subject   Re: st: Recode non-integers to positive integers
Date   Sat, 22 Aug 2009 01:25:04 +0000 (GMT)

Hi Frank,

There are many possible options.

Try

egen newvar=rank(oldvar), unique

This should work.  Note that the oldvar is the variable containing 2.87 to 6.04.  The newvar is a new variable you may specify differently to the oldvar.

I hope this helps.

Regards

Jon
________________________________
From: Frank Gallo <[email protected]>
To: [email protected]
Sent: Friday, 21 August, 2009 18:15:45
Subject: st: Recode non-integers to positive integers

Hi All,

I have a variable that has 28 unique non-integer values, which range from 2.87 to 6.04. I would like to recode the values to positive integers from 1 to 28 respectively. Is there a simpler way instead of "recode old var (2.87=1)....(6.04=28), generate(new var)" to accomplish this? Thank you.

Best,
Frank
*
*  For searches and help try:
*  http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/statalist/faqhttp://www.ats.ucla.edu/stat/stata/



      


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