Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[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   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to generate a dummy variable based on groups of variables in t-1
Date   Sat, 30 Apr 2011 11:14:02 +0100

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 <sandersn@stanford.edu> 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" <jean-marie.meier@web.de> 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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index