Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st:any easy alternative way when -egen- is not allowed to combine with by
From
Amanda Fu <[email protected]>
To
[email protected]
Subject
st:any easy alternative way when -egen- is not allowed to combine with by
Date
Tue, 21 Dec 2010 17:23:15 -0500
Hi all,
I notice some options of -egen- are not allowed to combine with by.
I just wondered if there is any good way to handle these situations.
Let me use an example.
----------------------------------------
ID surveyYear indicator (maximum value is 10)
1 1985 0
1 1986 1
1 1987 2
2 1985 0
2 1986 0
2 1987 0
...............
----------------------------------------
I want to create a variable "new" that takes value 1 if there is at
least one year for a ID's indicator is above 0 and takes the value 0
(like ID 1) is all the years the indicator is 0 (like ID 2).
What I wish to use is as following:
. bysort id: egen new=(indicator), anymatch(1/10)
Is there any simple way to do this? Any comments will be helpful. Thank you!
Sincerely,
Amanda Fu
*
* 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/