要求在实验组pay按以下规则匹配找出对照组,然后求其中值(peer):
配对规则是:
(1)同行业ind;
(2)同年度year;
(3)收入总额的0.5-2倍
程序如下:
use peer, clear
sort dm // dm为公司代码
save temp, replace
capture postclose match
postfile match group dm dmatch using matchsample1.dta, replace
local total = _N
local j = 0
forval i = 1/`total' {
preserve
local ldm = dm[`i']
local lyear = year[`i']
local lind = ind[`i']
local lshouru =shouru [`i']
quietly drop in `i' // 删除自身
quietly keep if ind == "`lind'"
quietly keep if year == `lyear'
gen shoururatio = abs(shouru / `lshouru' - 1)
quietly keep if (shoururatio >0.5& shoururatio <2)
if _N < 1 { // 若没有公司满足条件,则直接进入下一循环
restore
continue
}
bysort year ind shoururatio:egen peer1=median(pay)
----请高手予以修正,谢谢!