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]
Re: st: How to generate a dummy variable based on groups of variables in t-1
From
Austin Nichols <[email protected]>
To
[email protected]
Subject
Re: st: How to generate a dummy variable based on groups of variables in t-1
Date
Sat, 30 Apr 2011 07:22:32 -0400
Except use a lag operator (help tsvarlist), or first ensure there are
no gaps in panels.
egen industry_takeover = max(firm_takeover), by(industry year)
tsset firm year
gen takeover_last =L.industry_takeover
On Sat, Apr 30, 2011 at 6:14 AM, Nick Cox <[email protected]> wrote:
> That would be my hint too. On the correspondence any <-> max, all <->
> min, see (e.g.)
>
> FAQ . . Creating variables recording whether any or all possess some char.
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
> 2/03 How do I create a variable recording whether any
> members of a group (or all members of a group)
> possess some characteristic?
> http://www.stata.com/support/faqs/data/anyall.html
>
> Nick
>
> On Sat, Apr 30, 2011 at 11:09 AM, Nick Sanders <[email protected]> wrote:
>> Jean-Marie,
>>
>> I think you could do this with a combination of egen and sorting. Say your takeover indicator is firm_takeover. Then:
>>
>> egen industry_takeover = max(firm_takeover), by(industry year)
>> sort firm year
>> by firm : gen takeover_last = (industry_takeover[_n-1] == 1
>>
>>
>> That should do it!
>> -Nick
>>
>> On Apr 30, 2011, at 2:50 AM, "Jean-Marie Meier" <[email protected]> wrote:
>>
>>> Dear Stata list,
>>>
>>> It would be great if anyone could help me with this issue as I spent hours on it without solving it:
>>>
>>> I have a dataset with all companys listed on US stock exchanges from 1979 up to now.
>>> Every observation in my dataset are balance sheet and profit & loss account data for a given firm in a given year.
>>>
>>> I have a dummy variable, which is 1 for an observation if a firm was taken over and left the dataset - e.g. firm ABC was taken over in 1985, then for all observations up to 1984 for this firm the dummy variable is 0 and for the observation in 1985 the dummy variable is 1. If a firm was not taken over, than the dummy variable is obviously always 0.
>>>
>>> All firms/observations in my dataset are assigned an industry code between 1 and 48 (Fama French industry classification).
>>>
>>> My problem now is:
>>>
>>> How do I generate a dummy variable which is 1 for a given firm x and year t if there was a takeover in t-1 in the same industry (same industry code) and which is 0 otherwise ?
*
* 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/