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

st: RE: Converting continuous to indicator variables


From   "Frank de Libero" <[email protected]>
To   <[email protected]>
Subject   st: RE: Converting continuous to indicator variables
Date   Wed, 14 Aug 2002 16:17:14 -0700

Try gen age2534 = inrange(age,25,34)

..Frank

-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Deborah Garvey
Sent: Wednesday, August 14, 2002 3:49 PM
To: [email protected]
Subject: st: Converting continuous to indicator variables

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

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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