Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Converting continuous to indicator variables


From   "Deborah Garvey" <[email protected]>
To   <[email protected]>
Subject   st: Converting continuous to indicator variables
Date   Wed, 14 Aug 2002 15:49:24 -0700

Hi, all.

SAS has a nice way of creating indicator variables from continuous variables.  Let's say I want an age indicator equal to 1 for respondents ages 25 to 34 and 0 otherwise. (Missing data are not an issue here.)  In SAS I would simply type:

age 2534 = (25 le age le 34);

In STATA, however, the only way I know to create the same variable is to use gen:

gen age2534 = (age>=25 & age < 35)

Question:  Is there a better way to generate indicator variables from continuous ones?

Thanks,

Deb Garvey

******************************
Deborah Garvey, Ph.D.
Department of Economics
Kenna Hall
Santa Clara University
Santa Clara, CA  95053
408/554-4156
408/554-2331 (FAX)
[email protected]    
http://lsb.scu.edu/~dgarvey
**********************************
Hi, all.
 
SAS has a nice way of creating indicator variables from continuous variables.  Let's say I want an age indicator equal to 1 for respondents ages 25 to 34 and 0 otherwise. (Missing data are not an issue here.)  In SAS I would simply type:
 
age 2534 = (25 le age le 34);
 
In STATA, however, the only way I know to create the same variable is to use gen:
 
gen age2534 = (age>=25 & age < 35)
Question:  Is there a better way to generate indicator variables from continuous ones?
 
Thanks,
 
Deb Garvey
 
******************************
Deborah Garvey, Ph.D.
Department of Economics
Kenna Hall
Santa Clara University
Santa Clara, CA  95053
408/554-4156
408/554-2331 (FAX)
[email protected]   
http://lsb.scu.edu/~dgarvey
**********************************



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