Announcement

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

  • How to "table" into a putdocx or other

    Dear all, I am using Stata 16 and dealing with several descriptive stats as well as graphs, and I need to include these into a Word document. I will need to build several reports for different subsamples of my dataset using Word documents. I am trying to use "putdocx" which works well for graphs (I can use it to automatically include several graphs into the different sections of the document), but problems arise when trying different summary stats. For instance, what I need most is to include three level tables like:
    Code:
    table x1 x2 x3 if ..., c(n x4 m x5) col row
    Is it possible to use putdocx for this type of tables?
    If not, is there any way to export several tables like that one to a single Word, other than copy paste?

    Thanks in advance.

  • #2
    If not, is there any way to export several tables like that one to a single Word, other than copy paste?
    You could try asdoc (from SSC)
    For example

    Code:
    clear all
    
    webuse byssin 
    asdoc table workplace smokes race [fw=pop], c(mean prob) format(%9.3f) sc
    Click image for larger version

Name:	Screen Shot 2020-10-16 at 3.21.39 PM.png
Views:	1
Size:	131.0 KB
ID:	1577523

    Comment


    • #3
      Thanks for your help. It seems a very good way to go for tables. However, I have encountered some problems with the command. For instance, as it is in the asdoc help section example, it works perfectly, but if instead of one variable one stat, I ask for more than one variable stats it give error. For example:
      Code:
      . asdoc table workplace smokes race [fw=pop], c(m prob m sex) format(%9.3f) sc col row replace
      
      ------------------------------------------------------------------------
      Dustiness |                       Race and Smokes                       
      of        | ----------- other ----------    ----------- white ----------
      workplace |       no       yes     Total          no       yes     Total
      ----------+-------------------------------------------------------------
          least | .0107527  .0101523  .0104167    .0081549  .0162774   .012949
                | .6645162  .4500846  .5445076    .3486238  .3170559  .3299916
                | 
           less |      .02  .0081633  .0134831    .0136612  .0143149  .0140351
                |     .745  .0367347  .3550562    .0956284  .4642127  .3064328
                | 
           most | .0820896  .1679105  .1393035    .0833333  .2295082  .1835206
                | .7388059  .1529851  .3482587           1         1         1
                | 
          Total | .0250313  .0480072  .0383605    .0139762  .0345324  .0261661
                | .6971214  .2862319  .4587494    .3221523  .4115108  .3751422
      ------------------------------------------------------------------------
                     astable():  3301  subscript invalid
                       <istmt>:     -  function returned error
      r(3301);
      If I erase the "row" total option, then there is no problem (unfortunately I need the row total).

      Another problem I have seen is that if I only ask one stat for a single variable, then I can ask for the row total, but, the row total reported by Stata is not the same as the one placed in Word. For example:
      Code:
      . webuse byssin1, clear
      (Byssinosis incidence)
      
      . asdoc table workplace smokes race [fw=pop], c(n prob) format(%9.3f) sc col row replace
      
      ------------------------------------------------------
      Dustiness |              Race and Smokes              
      of        | ------ other ------    ------ white ------
      workplace |    no    yes  Total       no    yes  Total
      ----------+-------------------------------------------
          least |   465    591  1,056      981  1,413  2,394
           less |   200    245    445      366    489    855
           most |   134    268    402       84    183    267
                | 
          Total |   799  1,104  1,903    1,431  2,085  3,516
      ------------------------------------------------------
      Click to Open File:  Myfile.doc
      So , it seems it is doing the average, instead of what I asked for.

      Have anybody encountered the same problem? If so, is there a solution for this? I would like to use this command since it seems very good and flexible.

      Thanks in advance.

      Comment

      Working...
      X