Announcement

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

  • Simple table output

    Dear STATA users,

    I want a simple table output in word, however i can't seem to create it by just STATA commands.

    Situation sketch:
    - Three variables (X,Y,Z)

    Command used:
    . outreg2 using "Table 1.doc", replace sum(log) keep (X Y Z) eqkeep(mean sd min max)

    This is almost perfect, but i also want to add another column containing values from a different test, sktest --> (Prob>Chi2)

    Command used:
    sktest( X Y Z )

    This gives me a matrix of [3,4]

    Is there a command in which i can add this matrix to the existing Table 1.doc ?

    - I've searched this whole forum and tried many different things like:
    1. Adding the whole matrix to the outreg2 function with: addstat(Pvalues,r(Utest))
    2. Storing the last column of the matrix and adding it with outreg2: addstat(Pvalues,`matA')

    I've been able to add scalars with the outreg2 function, however these will appear as a row.
    I've been trying to add this with tabstat, but i haven't been successful with this as well.

    I think i may be thinking in the wrong direction.

    Kind regards

    Mark

  • #2
    This is where asdocx shines. We can create a table from any Stata command, and then modify the table in anyway you want. Let me present an example here, where we add the mention column to a summary table.


    Code:
    * Create descriptive statistics with asdocx
    asdocx sum invest mvalue kstock , replace
    
     sktest invest mvalue kstock
    
    * Store the results matrix
    mat table = r(table)
    
    * Get the p-value column
    mat pvalue =  table[....,5...]
    
    * Add the pvalue column to the summary statiscis at column 7
    asdocx addmat, matname(pvalue) right dec(3)
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	23.7 KB
ID:	1592897

    Comments:
    We added one additional column to the existing summary table that was created when we ran the asdocx sum command. The additional column was added using the flexmat package that comes with the asdocx installation. The flexmat program can be used both outside and inside asdocx (in the above example, we used it inside asdocx). The sub-command addmat belongs to flexmat program, with the matname() option specifying the matrix name which we want to add to the existing table. We also used the right option, that specified to append the matrix / column to the left of the existing table.
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment


    • #3
      Dear Dr Shah,

      Thank you very much, this is exactly what i need. I have experimented with 'asdoc'. However, for some reason i couldn't add two graphs together.
      Looking at your explanation i forget some essentials.

      Thanks for the fast response!

      Comment


      • #4
        In post #2 above, I referred to asdocx, not asdoc. These are different programs. Second, I showed an example of how to add a column to an existing table, you are talking about graphs. Yes, asdocx can export graphs, but asdoc cannot.
        Regards
        --------------------------------------------------
        Attaullah Shah, PhD.
        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        FinTechProfessor.com
        https://asdocx.com
        Check out my asdoc program, which sends outputs to MS Word.
        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

        Comment


        • #5
          I meant tables, sorry for the confusion.

          Comment

          Working...
          X