I like Ichiro's solution. Another way to do it is
egen indicator = max(year == 1990 & index > 100 & index < .) , by(country)
Nick
[email protected]
Ichiro Fujikake
> If the first year is always 1990, this should do the job.
>
> bysort country (year): gen indicator= index[1]>100
>
> Otherwise, how about this?
>
> gen indicator= year==1990 & index>100
> bysort country (indicator): replace indicator=indicator[_N]
>
> If index can be missing in 1990, you should also take care of it.
>
Jason Hwang
> > I have panel data of the following form:
> >
> > country year index
> > 1 1990 97
> > 1 1991 103
> > 1 1992 107
> > 2 1990 102
> > 2 1991 112
> >
> > I want to be able to say: if the value of the "index"
> variable in 1990 was
> > greater than, say, 100, then I want to create an indicator
> variable=1 for
> > that country for all years. How would I do this? I can't do
> something like
> >
> > gen indicator=1 if year==1990 & index>100
> >
> > since this would apply only to 1990 and not the other
> years. How do I reference a specific country-year cell when I want to use
> the reference in a command that applies to the entire dataset?
> >
> > (a way other than the brute force method which would keep only 1990,
> > creating the indicator variable, save as a separate file,
> then merge it back to the original data.)
*
* 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/