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 Nick Sanders 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 03:09:49 -0700

```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

Sent from my iPhone - please excuse typos and/or brevity.

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 ?
>
> Looking forward to your answers
>
> Kind regards,
>
> Jean-Marie Meier
> *
> *   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/

*
*   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–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index