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

From |
Michael Hanson <mshanson@mac.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: help with encode |

Date |
Fri, 24 Jul 2009 07:02:01 -0400 |

replace gender = gender - 2 (Subtract 1 if you had 1's and 2's as mentioned in your original post.)

3.3 Stata references in your question

Hope this helps, Mike On Jul 24, 2009, at 4:09 AM, Miranda Kim wrote:

I tried this but couldn't make it work, as it then automaticallyencodes the variables with 2's and 3's...Nick Cox wrote:In addition to other answers the direct answer to the secondquestion is"Yes": label def female 0 "m" 1 "f" encode gender, gen(female) label(female) It would no harm to check on any missings: tab gender if !inlist(female, 0, 1) Nick n.j.cox@durham.ac.uk Miranda KimHow can I efficiently convert string variables (such as gender withvalues 'f' 'm') into binary 0/1 variables?Can I fiddle with encode so that it codes 0/1 instead of 1/2?

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

**Follow-Ups**:**Re: st: RE: help with encode***From:*Miranda Kim <mk@mrc.soton.ac.uk>

**References**:**st: help with encode***From:*Miranda Kim <mk@mrc.soton.ac.uk>

**st: RE: help with encode***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: help with encode***From:*Miranda Kim <mk@mrc.soton.ac.uk>

- Prev by Date:
**Re: st: Wald test across equations after ivregress or ivreg2** - Next by Date:
**Re: st: RE: help with encode** - Previous by thread:
**RE: st: RE: help with encode** - Next by thread:
**Re: st: RE: help with encode** - Index(es):

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