Announcement

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

  • Export results of Gtools to excel or word

    Hi,

    I would like to export results of gstats tab (part of gtools) to excel or word. Can anyone help me with this issue?
    https://gtools.readthedocs.io/en/lat...ats_summarize/

    Here is the some of the code that Dr. Shah helped me with but I am unable to get it exported to excel or word with variable names. The reason I am having difficulty is that
    according to mata GstatsOutput.desc()
    there are two variable names(it repeats in the table) and I cannot get it to the table itself.



    [CODE]
    sysuse auto, clear gstats tab price mpg, by(foreign rep78) matasave * Get the statistics matrix from the GstatsOutput class * Note: We need to convert the real matrix to string first mata stat_values = strofreal(GstatsOutput.output) * Get the names of the statistics mata stat_names = GstatsOutput.statnames * Combine the two matrices mata outtable = stat_names \ stat_values * Add the matrix to asdocx system flexmat reset flexmat addmat, matname(outtable) * Export to word asdocx export 0 |1 2 3 4 5 6 ----+------------------------------------------------------------------------------------------- 1 |n sum mean min max sd ----+------------------------------------------------------------------------------------------- 2 |2 9129 4564.5 4195 4934 522.5519 3 |2 42 21 18 24 4.242641 4 |8 47741 5967.625 3667 14500 3579.357 5 |8 153 19.125 14 24 3.758324 6 |27 178391 6607.074 3291 15906 3661.267 7 |27 513 19 12 29 4.085622 8 |9 52934 5881.556 3829 8814 1592.019 9 |9 166 18.44444 14 28 4.585605 10 |2 8409 4204.5 3984 4425 311.8341 11 |2 64 32 30 34 2.828427 12 |4 19162 4790.5 3799 6486 1169.903 13 |4 93 23.25 19 26 3.40343 14 |3 14486 4828.667 3895 6295 1285.613 15 |3 70 23.33333 21 26 2.516611 16 |9 56353 6261.444 3995 9735 1896.092 17 |9 224 24.88889 21 30 2.713137 18 |9 56634 6292.667 3748 11995 2765.629 19 |9 237 26.33333 17 41 9.367497 20 |1 12990 12990 12990 12990 . 21 |1 14 14 14 14 . ------------------------------------------------------------------------------------------------ [/CODE]

    Thank you.

    Ozer

  • #2
    Ozer Erdem It seems that while doing this is possible, it's more cumbersome than I'd realized. Upgrade to the latest in the develop branch and try out the suggestion in https://github.com/mcaceresb/stata-g...ent-1438810327

    Comment


    • #3
      Thank you. It works great.

      Comment

      Working...
      X