[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Referencing Specific Cell in Panel Data
If the first year is always 1990, this should do the job.
bysort country (year): gen indicator= index>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.
On 04.11.5 11:08, "Jason Hwang" <email@example.com> wrote:
> 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.)
> Thanks for your help!
> * 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/
* For searches and help try: