clear all clear mata set more off set matsize 10000 cd "$path" ************************ Creating folders ************************************ local folder "Phi" cd "$path/Output" capture confirm file "./`folder'/nul" if _rc { !md "`folder'" } local folder "Estimation" cd "$path/Output" capture confirm file "./`folder'/nul" / if _rc { !md "`folder'" } local folder "Raw" cd "$path/Output/Estimation/" capture confirm file "./`folder'/nul" if _rc { !md "`folder'" } ******************************************************************************* use "$path/Output\ready for estimation.dta" levelsof nace_group,local(levels) foreach section in `levels'{ clear mata set more off set seed 12345 use "$path/Output\ready for estimation.dta",clear keep if nace_group== `section' global id id global t year xtset $id $t global section `section' global bootstrap_reps=1000 forvalues boot_count=0(1)$bootstrap_reps { global boot_count=`boot_count' dis `boot_count' preserve if `boot_count'==0 { tempfile org_set qui do "$path/1.1 first stage estimation.do" qui do "$path/1.2 second stage estimation.do" qui do "$path/1.3 markup estimation.do" save `org_set' } restore else { preserve bsample, cluster(${id}) idcluster(new_id) replace ${id}=new_id drop new_id xtset ${id} $t qui do "$path/1.1 first stage estimation.do" qui do "$path/1.2 second stage estimation.do" qui do "$path/1.3 markup estimation.do" restore } } use `org_set', clear gen omega=phi-beta_l*l-beta_k*k gen beta_l = beta_l gen beta_k = beta_k gen se_l = se_l gen se_k = se_k save "$path/Output\Estimation/Raw/sva_sector_`section'_results.dta",replace } clear all cd "$path/Output/Estimation/Raw" fs "*_results.dta" append using `r(files)' foreach v in theta_l mu omega beta_l beta_k se_l se_k{ rename `v' `v'_sva } save "$path/Output/Markups_SVA.dta",replace ******************************Table 2***************************** use "$path/Output/Markups_SVA.dta",replace table (var) (nace_group), nformat(%5.2f) statistic(mean beta_l_sva se_l_sva beta_k_sva se_k_sva ) nototal collect style cell var[se_l_sva se_k_sva], sformat((%s)) collect label levels nace_group 1 "Manufacturing" 2 "Utilities" 3 "Construction" 4 "Trade" 5 "Services" , modify collect label levels var beta_l_sva "Labor" beta_k_sva "Capital", modify collect style header var[se_l_sva se_k_sva], level(hide) collect style header nace_group, title(hide) cd "$path" collect export table_2.tex,replace