Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Marcello Pagano <pagano@hsph.harvard.edu> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Assigned sex |
Date | Thu, 23 Dec 2010 14:04:48 -0500 |
and yet only one person complained!!!! m.p. On 12/23/2010 1:04 PM, Lachenbruch, Peter wrote:
This is such a disappointing email after a tempting title... Tony Peter A. Lachenbruch Department of Public Health Oregon State University Corvallis, OR 97330 Phone: 541-737-3832 FAX: 541-737-4001 -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Phil Clayton Sent: Wednesday, December 22, 2010 5:08 AM To: statalist@hsphsun2.harvard.edu Subject: Re: st: Assigned sex Use -encode- to convert the sex variable to a numeric one, eg: label define male 0 "F" 1 "M" encode sex, label(male) gen(male) Note that I've made the values 0 and 1, rather than 1 and 2, because this makes "male" a dummy variable suitable for regression. Phil On 22/12/2010, at 11:50 PM, Marcello Pagano wrote:-------- Original Message -------- Dear stata-listers, I would like some help is using the 'recode' command (or any other appropriate one) to reformat one of my variables. The variable 'sex' describes what sex each of my subjects is assigned to. The variable looks like this: . sum sex Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- sex | 0 . tab sex c:sex | Freq. Percent Cum. ------------+----------------------------------- F | 584 48.50 48.50 M | 620 51.50 100.00 ------------+----------------------------------- Total | 1,204 100.00 As you can see the above variable isn't particularly useful for regression, and basic statistics that I would like to use it for. How would I somehow recode the variable, such that all boys are coded as 1 and girls as 2?? And the number of observations will be listed as 1,204 when the variable is summarized? As of now the varibale is the 'str1' format. Thanks! /Amal. Amal Khanolkar, PhD candidate, Centre for Health Equity Studies (CHESS), Karolinska Institutet, 106 91 Stockholm. * * 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/ * * 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/