Announcement

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

  • Saving result as table

    Hello Everyone,

    I am running the command mhtexp, from the mhtexp package, which I installed through ssc. When I run the command I get a result such as the one below:

    . mhtexp score_ha, treatment(groupe_etab_13)

    | outcome subgroup treatme~1 treatme~2 diff_in~s Remark3_1 Thm3_1 Remark3_7 Bonf Holm
    -------------+------------------------------------------------------------------------------------------------------------------------------------------------
    r1 | 1 1 0 1 .0001479 .961 .961 .961 .961 .961

    However, I don't know how to access the result. I have tried result list, eresult list, sresult list, and they return nothing.
    I have tried saving the log, but I can't find a way to save it in the form of a table, or a form that I can easily manipulate later to create a table.
    I have also tried something like:

    tempname res_matrix
    matrix `res_matrix' = mhtexp score_ha, treatment(groupe_etab_13)

    but it says that the command mhtexp is not recognized.

    Any suggestions?

    Thank you in advance,
    Guadalupe

  • #2
    If you tried -result list-, -eresult list-, and -sresult list-, then surely you got error messsages, not just nothing, as those commands do not exist. Did you mean you tried -return list-, -ereturn list-, and -sreturn list-? If not, try those.

    If you did try -return list-, etc. and there is no output from those, then you are rather stuck. If you have only a small number of such outputs to deal with, you are probably best off copy/pasting them from the log file or Results window into a new Stata data set--not really desirable as it leaves no audit trail and, depending on how that output is punctuated, may be difficult and tedious. If you have many such outputs to deal with, or find the objections to copy/pasting convincing, your options in this case are:

    1. Contact the author of mhtexp and ask if perhaps he/she has updated the code to include returning output.
    2. Try to hack mhtexp.ado yourself to make it an -rclass- program and return its results in r().
    3 Run the program while logging the results in a text file. Then write a program using the -file- commands to read in that log file, parse out the results and store them in a datafile (perhaps a -postfile-).

    I don't think there are any easier options here.

    Comment


    • #3
      Yes, I apologize, I meant "return list, ereturn list, sreturn list"

      I will try your other suggestions. Thank you

      Comment


      • #4
        If you attempt copy-and-paste from the Results window (or perhaps from the log file when viewed in Stata's viewer window) you may find the "Copy table" command on Stata's Edit menu helps turn the tabular results into tab-delimited text that you can paste into, for example, Word or Excel.

        Comment


        • #5
          I came across this thread today when facing a similar issue. The solution I came to was to save the cell values from the results matrix as a scalar and then save that as a local that I called on when exporting values to tables. For example, given a set of outcomes, the following code grabs the Holm correction (which appears in the final column/the 10th column for -mhtexp- that I run below) for the first outcome. Although still inelegant as you'll have to hard-code the exact row/column you want, it provides more of an audit trail.

          Code:
          mhtexp `outcomes', treatment(`treatvar')
          scalar holm_1=results[1,10]
          local holm_1: display %5.3f holm_1
          I'm using Stata version 15.1

          Comment

          Working...
          X