clear capture log close log using "$pathlog\12_Residential Schedule 135 Margin of Error Tally_$S_DATE.log",replace forvalues x=1/12{ forvalues y=48/59{ quietly append using "$pathout135res\04_Schedule 135 Residential Montly Interval Total Exports_`x'_`y'_14 Jul 2020.dta" } } drop if Exports_moe_pe==. count if Exports_moe_pe<.1 gen moe_100=Exports_moe_pe * 100 sum moe_100,d sum moe_100 if Peak==1,d rename *,lower sort month order format exports_total exports_margin exports_moe_pe moe_100 %20.2fc collapse (mean) moe_100 export excel moe_100 using "$pathexcelsurr\Exhibit 2-AJL.xlsx",sheetmodify sheet("Sch 135 Res")cell(A2), putexcel set "$pathexcelsurr\Exhibit 2-AJL.xlsx",sheet("Sch 135 Res") modify putexcel A1="Margin as a Percentage", bold save "$pathout135res\12_combined schedule 135 residential moe_$S_DATE.dta",replace log close