Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: replace var with if range condition


From   David Radwin <[email protected]>
To   [email protected]
Subject   Re: st: replace var with if range condition
Date   Wed, 22 Aug 2007 14:59:49 -0700

I think what you want is the single line

gen age1 = inrange(age,20,24)

Note that it will return 1 for the endpoints of the range, 20 and 24. It might be a good idea to double check with

tab2 age age1

For more help, -help inrange-

David

At 9:23 AM -0700 8/22/07, Ziad El-Khatib wrote:

Dear StataLister,
Any tips how to write condition replace to make condition in case of range?
Example:
variable name is age

gen age1 = 0
replace age1 = 1 if age is between 20 and 24  ?

--
David Radwin, Principal Analyst // [email protected]
Office of Student Research, University of California, Berkeley
2223 Fulton St # 2032, Berkeley, CA 94720-2032
Tel. 510.642.2097; Fax 510.642.2894
*
*   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