在sungmoo对某帖的回复中,有这样一个例子:
要求配对标准如下:
(1)同年度year。
(2)同行业ind。
(3)asset最接近,即对照组与试验组asset的差的绝对值最小。
(4)每个对照组观测值只能配对一次,不同年份之间也不能重复。
命令如下
use match4.dta, clear
bys year ind sp (stkcd):g exp=_n if sp
bys year ind :egen s=max(exp)
drop if s==.
expandcl s if !sp,cl(year stkcd) gen(g)
bys year stkcd:replace exp=_n if !sp
bys year ind exp:egen r=sum(asset*sp)
g q=abs(asset-r) if !sp
sort q stkcd
count if q<.
loc m=r(N)
forv i=1/`m'{
loc v=stkcd[`i']
replace q=. if stkcd==`v'&_n>`i'&!sp
}
drop if q==.&!sp
bys year ind exp:egen u=min(q) if !sp
drop if u!=q&!sp
egen mat=group(year ind exp)
drop exp-u
sort mat sp
要是再加上一个相近的上市年龄listage应该怎么做呢?