Statalist The Stata Listserver


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

Re: st: How to quickly replace values of a variable


From   "Quang Nguyen" <quangn@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to quickly replace values of a variable
Date   Wed, 31 Jan 2007 22:17:35 -1000

Dear Svend,

Thanks so much for your quick help. I highly appreciate it. I am sorry
for not being specific in my question. Actually, there is no "rule"
relating the old values to the new values. E.g., 101 replaced by
65687; 102 by 65686; 103 by 73128 and so on. Thus, I can use:

recode id (101=65687) (102=65686) (103=73128) and so on

Alternatively, I can create another file containing information on the
new values of ID. Then, I match the new file and the original file.

Is there any better way of doing this?
Thanks so much and Have A Great Day!

On 1/31/07, Svend Juul <SJ@soci.au.dk> wrote:
Quang wrote:

I have the following simple data:
permit
101
101
102
102
103
103
104
104
105
105
105
....

There are about 300 observations. I would like to replace 101 by
65687, 102 by 65686, and so on. ....
-----------------------------------------------------------------

If I understand your rule correctly, it is simple:
  generate permit2 = 65788-permit

Strong recommendation: Create a NEW variable, leaving the original
variable unchanged.

Svend
__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: sj@soci.au.dk
__________________________________________

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

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