Erasmo Giambona <[email protected]>:
Is this the kind of setup you are talking about? Firms with id number
higher than 5918 present no problem.
clear
range year 1980 2005 26
expand 6000
bys year: g firm=_n
g y=uniform()
g x=uniform()
tsset firm year
sort firm year
g double d=.
qui forv i=3/`=_N-2' {
loc f=`i'-2
loc l=`i'+2
if firm[`f']==firm[`i'] & firm[`l']==firm[`i'] {
cap reg y year in `f'/`l' if firm==firm[`i']
if _rc==0 {
if e(N)>2 {
predict double ye if e(sample), resid
reg x year in `f'/`l' if firm==firm[`i']
predict double xe if e(sample), resid
reg ye xe
replace d=_b[xe] in `l'
drop ye xe
}
}
}
}
li, noo sepby(firm)
g ok=d<.
tab year ok
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/