[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Programming a loop to exclude M&As in the 5 years prior to an M&A

From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: Programming a loop to exclude M&As in the 5 years prior to an M&A
Date   Thu, 16 Oct 2008 13:21:13 +0200

Not fully understanding your prob, let me comment on two aspects: Firstly,
it is not clear to me why you include the first line and set -local j- equal
to 1987. The next line tells Stata exactly which values -j- should acquire
in the loop as in

loc i=1
forv i=3/5{
di `i'

The first line is harmless, but also redundant.

Secondly, it is not a good idea to -drop- observations left and right.
Instead, create an indicator variable for your -if- qualifiers. Simply do
something along these lines in your loop:

g indicator=0
replace indicator=1 if acquiror_cusip==acquiror_cusip &

Later you can condition your analyses on this indicator, but can go back to
the original data if needed. 

BTW, the FAQ on such problems are quite comprehensive and helpful
( Also check the contents of the Stata
Journal archive, part of which is free:


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Thursday, October 16, 2008 12:03 PM
To: [email protected]
Subject: st: Programming a loop to exclude M&As in the 5 years prior to an

Hello Statausers,

I am new to STATA and try to program a screening loop to exclude from  
my SDC M&A sample those M&As in which the acquiror or target of an M&A  
in a particular year_of_announcement==`j' with j=1987-2006 has been  
the target or acquiror in an M&A in one of the preceeding 5 years.  
This screening is needed to avoid the problem of overlapping events in  
the analysis of the stock returns after the M&A.

My problem is how to program that STATA is supposed to look in a  
particular year for all acquirors and targets that are acquirors or  
targets in one of the past 5 years. The target_cusip and  
acquiror_cusip as identifiers are organized in seperate colums. So  
STATA has to go through these two colums in each year and look for  
duplicated cusips that occur already in the year_of_announcement  
looked at.

So far I programmed the following loop, but do not know how to  
indicate that the year_of_announcement==`j' is the base year from  
which Stata has to go back year by year to look for the cusips  
occuring in year j that are duplicated in the previous years :

local j=1987
forvalues j=1987/2006 {

	drop if acquiror_cusip==acquiror_cusip & year_of_announcement==`j'-1
	drop if acquiror_cusip==target_cusip & year_of_announcement==`j'-1
	drop if target_cusip==target_cusip & year_of_announcement==`j'-1
	drop if target_cusip==acquiror_cusip & year_of_announcement==`j'-1

	drop if acquiror_cusip==acquiror_cusip & year_of_announcement==`j'-2
	drop if acquiror_cusip==target_cusip & year_of_announcement==`j'-2
	drop if target_cusip==target_cusip & year_of_announcement==`j'-2
	drop if target_cusip==acquiror_cusip & year_of_announcement==`j'-2

	drop if acquiror_cusip==acquiror_cusip & year_of_announcement==`j'-3
	drop if acquiror_cusip==target_cusip & year_of_announcement==`j'-3
	drop if target_cusip==target_cusip & year_of_announcement==`j'-3
	drop if target_cusip==acquiror_cusip & year_of_announcement==`j'-3

	drop if acquiror_cusip==acquiror_cusip & year_of_announcement==`j'-4
	drop if acquiror_cusip==target_cusip & year_of_announcement==`j'-4
	drop if target_cusip==target_cusip & year_of_announcement==`j'-4
	drop if target_cusip==acquiror_cusip & year_of_announcement==`j'-4

	drop if acquiror_cusip==acquiror_cusip & year_of_announcement==`j'-5
	drop if acquiror_cusip==target_cusip & year_of_announcement==`j'-5
	drop if target_cusip==target_cusip & year_of_announcement==`j'-5
	drop if target_cusip==acquiror_cusip & year_of_announcement==`j'-5

I gues a command with a varlist like forvalues j=1987/2006 of varlist  
year_of_announcement {.....}

Kind regards

Pascal Stock

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index