Statalist


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

st: AW: help with encode


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: help with encode
Date   Thu, 23 Jul 2009 16:22:10 +0200

<> 

You could also forget about converting and just create a new dummy in a
straightforward way:

*************

clear*

input str1 gender
m
f
f
m
f
m
m
f
m
end

compress
list, noobs  

gen male=gender=="m"
ta male
l
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Miranda Kim
Gesendet: Donnerstag, 23. Juli 2009 15:21
An: statalist@hsphsun2.harvard.edu
Betreff: st: help with encode

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?
Many thanks


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


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index