* Reproduces Tables OA10, OA11, OA12
clear all
cls
log using summarize_BWE_DV_deseason.txt, text replace 
use "cogs_deflated_deseason.dta", clear

gsort gvkey_code -datacqtr
//BWEall DVall are computed for firms active in Q4 2014
replace bweall = . if datacqtr~=20144
replace sd_cogsqdall = . if datacqtr~=20144

//tabulating BWE and DV and running the significance test for BWE (Tables 4, A1, A2, A3)
local BWEvars = "bwed bwed4 bwed12 bweall"
foreach BWE of local BWEvars {	
	estpost tabstat `BWE', by(dist1)  statistics(n p50 p25 p75 mean sd) col(stat)
	esttab using "bylayer_`BWE'_deseason.tex" , cells("count p50(f(%8.4f)) p25(f(%8.4f)) p75(f(%8.4f)) mean(f(%8.4f)) sd(f(%8.4f))" )  noobs nomtitles label replace
	*bys dist1: centile `BWE', level(99)
}

local DVvars = "sd_cogsqd sd_cogsqd4 sd_cogsqd12 sd_cogsqdall"
foreach DV of local DVvars {	
	estpost tabstat `DV', by(dist1)  statistics(n p50 p25 p75 mean sd ) col(stat)
	esttab using "bylayer_`DV'_deseason.tex" , cells("count p50(f(%8.4f)) p25(f(%8.4f)) p75(f(%8.4f)) mean(f(%8.4f)) sd(f(%8.4f))" )  noobs nomtitles label replace
}



log close
exit
