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]

From |
"Jean-Marie Meier" <jean-marie.meier@web.de> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: How to generate a dummy variable based on groups of variables in t-1: Simple solution |

Date |
Mon, 2 May 2011 15:58:52 +0200 (CEST) |

Hi, first, thanks to all that helped me. When I was testing the proposals I got for my problem, I suddenly had an idea how to do it in a quick and nice way: The problem was: 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 ? First, for clarity, drop all variables except industry code dummy_whether_firm_was_taken_over firm identifier year The 3 line solution then is: keep if dummy_whether_firm_was_taken_over == 1 (only observations remaining firms and the year in they which were taken over (firms that are taken over leave the dataset anyhow)) duplicates drop industry_code year, force (as I want a dummy variable which is 1 if there was a takeover in an industry in t-1, I use the duplicate command for industry code and year, so that for every industry code and year combination I have one observation if there was takeover in the industry and none if there wasn't replace year = year+1 (as I wanted to know, whether there was a takeover in the industry the year before, I simply add 1 to the year variable, then I save the dataset and perform a m:1 merge with the original dataset as master file) Kind regards, Jean-Marie 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/

- Prev by Date:
**Re: st: Re: insheet multi threading** - Next by Date:
**Re: st: cross grouping a family w siblings and stepsiblings** - Previous by thread:
**st: worker specific time trends** - Next by thread:
**Re: st: cross grouping a family w siblings and stepsiblings** - Index(es):