各位大侠,大家好!
我在
.dta数据中做配对,配对标准是:同年度、同行业、资产+-20%,ROA最为接近
引用了
https://bbs.pinggu.org/thread-696047-1-1.html中voodoo编写的程序(修改后如下),
执行时,但是总是出现“C not found”
我很困惑究竟问题出在哪里?
敬请各位大侠帮助解开我的困惑,不胜感激!
before_match.dta在附件里。
下面是程序:
capture postclose match
postfile match group id year dmatch using matchsample.dta, replace
local total = _N
local j = 0
forval i = 1/`total' {
preserve
local lid = id[`i']
local lyear = year[`i']
local lindus = indus[`i']
local lROA = ROA[`i']
local la001000000 = a001000000[`i'] //资产
quietly drop in `i' // 删除自身
quietly keep if indus == `lindus'
quietly keep if year == `lyear'
gen assetratio = abs(a001000000 / `la001000000' - 1)
quietly keep if assetratio <= 0.2 // 将条件分成四句keep if ,有助于加快程序
if _N < 1 { //若没有一个公司满足条件,则直接进入下一循环
restore
continue
}
sort ROA // 对ROA排序
local mid = id[1] //若有多个公司满足条件,则用ROA最接近的公司
local j = `j' + 1
post match (`j') (`lid') (`lyear') (0)
post match (`j') (`mid') (`lyear') (1)
restore
}
postclose match
use matchsample, clear
sort id year
merge id year using befor_match
keep if _merge == 3
drop _merge
sort group dmatch
label define ldmatch 0 "初始样本" 1 "配对样本"
label value dmatch ldmatch
list in 1/30