Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transferring p-value of t-test do an existing excel file using stata command

    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 Click image for larger version

Name:	summary.png
Views:	1
Size:	25.3 KB
ID:	1730306 Click image for larger version

Name:	pvalue.png
Views:	1
Size:	28.0 KB
ID:	1730307 file intact. How can I do this using stata code?
Working...
X