Announcement

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

  • Exporting STATA results to excel: Why colwise does not give me the results of my matrix in one row using putexcel?

    Dear Statisticians,

    I have a problem to get the results of putexcel in columns (i.e. using colwise option). Here is the example command that I have for STATA 13:

    tabstat Lectured, statistics(count sum mean min p25 p50 p75 max) save
    putexcel A1=matrix(r(StatTotal), names) using test.xlsx, sheet("Results") colwise replace

    I don't understand why still the results that I get in excel are in one column. Could you please help me why colwise does not work?! I need the results of my matrix in one row in excel.

    Thanks for your responses everyone!

    Click image for larger version

Name:	Test_colwise.jpg
Views:	1
Size:	33.7 KB
ID:	1370454



  • #2
    The colwise option writes each matrix in consecutive columns. Since you
    only have one matrix, putexcel writes the matrix in one column. You must
    transpose the matrix before using putexce to get the table you want.

    Code:
    sysuse auto, clear
    tabstat mpg, stat(count sum mean min p25 p50 p75) save
    matrix a = r(StatTotal)'
    putexcel set jj, replace
    putexcel A1=matrix(a), names

    Comment

    Working...
    X