家人们我的安慰剂检验一直出不来图  之前出的图只有一个篮圈 现在代码改了改 连图都出不来了
解释变量did 被解释变量Financial 控制变量x1 x2 x3 x4 x5 x6
家人们能帮我看看代码吗
mat b=J(500,1,0)    
mat se=J(500,1,0)
mat p=J(500,1,0)
forvalues i = 1/500{
use "C:\Users\A\Desktop\制造业数据.dta"  
duplicates drop id year, force
xtset id year
keep if year==2020     
sample 11883,count        
keep id
save matchcity.dta,replace
merge 1:m id using "hczl2.dta"
gen treat1=(_merge==3)
save matchcity`i'.dta,replace 
use "C:\Users\A\Desktop\制造业数据.dta" 
bsample 1,strata(id)
keep year
save matchyear.dta,replace
mkmat year,matrix(sampleyear)
use matchcity`i'.dta,replace
duplicates drop id year, force
xtset id year
gen Time=0
foreach j of numlist 1/30292{
replace Time=1 if id==`j' & year>=sampleyear[`j',1])
}
gen DID1=Time*treat1
global X "x1 x2 x3 x4 x5 "
qui xtreg Finacial did xi x2 x3 x4 x5 i.year,fe r
mat b[`i',1]= _b[DID1]
mat se[`i',1]= _se[DID1]
scalar df_r=e(N)-e(df_m)-1
mat p[`i',1]=2*ttail(df_r,abs(_b[DiD1]/_se[DID1]))
}
svmat b,names(coef)
svmat se,names(se)
svmat p,names(pvalue)
drop if pvalue==.
label var pvalue P值
label var coef1 估计系数
twoway(scatter pvalue1 coef1,xlabel(-0.1(0.001)0.1grid) yline(0.1,lp(shortdash)) xline(-0.0305,lp(shortdash)) xtitle(估计系数) ytitle(p值) msymbol(smcircle_hollow) mcolor(blue) legend(off))(kdensity coef1,title(安慰剂检验))
forvalue i=1/500{
erase matchcity`i'.dta
}