Statalist


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

AW: st: RE: help with encode


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: RE: help with encode
Date   Fri, 24 Jul 2009 11:38:58 +0200

<> 

"That should read xi i.gnder as martin rightly says.."



We cannot possibly know what Miranda`s variable name is, but just for the
record: I said "xi i.gender", not "xi i.gnder"



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Tharyan, Rajesh
Gesendet: Freitag, 24. Juli 2009 11:36
An: [email protected]
Betreff: RE: st: RE: help with encode

That should read xi i.gnder as martin rightly says..
r 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Tharyan, Rajesh
Sent: 24 July 2009 10:28
To: [email protected]
Subject: RE: st: RE: help with encode

Hi,

Just xi: i.gender would do...sorry!

R

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Martin Weiss
Sent: 24 July 2009 10:24
To: [email protected]
Subject: AW: st: RE: help with encode


<> 

If that is what you really want, why not just


*************
xi i.gender
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Tharyan, Rajesh
Gesendet: Freitag, 24. Juli 2009 11:21
An: [email protected]
Betreff: RE: st: RE: help with encode

Hi,

In addition to all the useful comments people have made.. Here is a nother
way.

Try 

qui xi: reg i.gender

This will create a variable  _Igender_1 with zeros and ones

Hope this helps
rajesh


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Miranda Kim
Sent: 24 July 2009 09:10
To: [email protected]
Subject: Re: st: RE: help with encode

I tried this but couldn't make it work, as it then automatically encodes 
the variables with 2's and 3's...

Nick Cox wrote:
> In addition to other answers the direct answer to the second question 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 
> [email protected] 
>
> 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:
> *   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/

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



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