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

st: RE: help with encode

From   "Nick Cox" <>
To   <>
Subject   st: RE: help with encode
Date   Thu, 23 Jul 2009 17:01:00 +0100

In addition to other answers the direct answer to the second question is

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) 


Miranda Kim

How can I efficiently convert string variables (such as gender with 
values '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:

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