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" <>
To   <>
Subject   st: RE: Converting continuous to indicator variables
Date   Wed, 14 Aug 2002 16:17:14 -0700

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


-----Original Message-----
[]On Behalf Of Deborah Garvey
Sent: Wednesday, August 14, 2002 3:49 PM
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 age2534 = (age>=25 & age < 35)

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


Deb Garvey

Deborah Garvey, Ph.D.
Department of Economics
Kenna Hall
Santa Clara University
Santa Clara, CA  95053
408/554-2331 (FAX)

*   For searches and help try:

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