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

Re: st: Simple recoding


From   Antoine Terracol <[email protected]>
To   [email protected]
Subject   Re: st: Simple recoding
Date   Fri, 16 Aug 2002 13:54:33 +0200

Try
gen sex2=(sex=="F")+1
drop sex
rename sex2 sex

Antoine.


[email protected] wrote:

Hello statalisters,

I have a variable in my datasheet, sex which is formatted as str1 %9s.
There are two types either M or F.  I need to convert this so that M=1 and
F=2. How do I do this, or where is a problem similar to this described.  I
have tried using "destring sex, replace" etc but have had no luck.
Thanks for all your help in advance on this relatively simple question.

Christopher D Fergusson
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index