clear
sysuse auto.dta
putexcel set "............\SummaryStatistics.xls", sheet("Sheet1") replace
putexcel A1 = "Variable"
putexcel B1 = "Foreign(mean)"
putexcel C1 = "Foreign(sd)"
putexcel D1 = "Domestic(mean)"
putexcel E1 = "Domestic(sd)"
//calculating mean//
tabstat price mpg rep78 headroom trunk weight length turn displacement gear_ratio,by(foreign) statistics(mean) save
return list
qui tabstat price mpg rep78 headroom trunk weight length turn displacement gear_ratio,by(foreign) statistics(mean) save
matrix Foreign = r(Stat2)'
matrix Domestic = r(Stat1)'
putexcel A2 = matrix(Foreign), rownames nformat(number_d2)
putexcel D2 = matrix(Domestic), nformat(number_d2)
Using this command I have created an excel file given below.
Now i have done a ttest,
estpost ttest price mpg rep78 headroom trunk weight length turn displacement gear_ratio, by(foreign)
using this code i got the p-value as e(p). Now I want to export this e(p) value to the existing excel file in column F keeping the existing Excel
file intact. How can I do this using stata code?
sysuse auto.dta
putexcel set "............\SummaryStatistics.xls", sheet("Sheet1") replace
putexcel A1 = "Variable"
putexcel B1 = "Foreign(mean)"
putexcel C1 = "Foreign(sd)"
putexcel D1 = "Domestic(mean)"
putexcel E1 = "Domestic(sd)"
//calculating mean//
tabstat price mpg rep78 headroom trunk weight length turn displacement gear_ratio,by(foreign) statistics(mean) save
return list
qui tabstat price mpg rep78 headroom trunk weight length turn displacement gear_ratio,by(foreign) statistics(mean) save
matrix Foreign = r(Stat2)'
matrix Domestic = r(Stat1)'
putexcel A2 = matrix(Foreign), rownames nformat(number_d2)
putexcel D2 = matrix(Domestic), nformat(number_d2)
Using this command I have created an excel file given below.
Now i have done a ttest,
estpost ttest price mpg rep78 headroom trunk weight length turn displacement gear_ratio, by(foreign)