Announcement

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

  • putdocx and sumat: add header with categoric names

    Hi all

    I am using sumat from SSC in Stata 17 to export 2 way table to putdocx.

    It work fine but I am having problem with adding header with categoric names when I export table to putdocx , example:

    Code:
    clear all
    sysuse auto
    
    putdocx begin
    
    *Work fine headers are ok:
    
    sumat mpg, statistics(mean sd) rowby(rep78) colby(foreign) decimals((2,2,2,2,2,2))  
    
    
    ----------------------------------------------------------------------------
                           Car origin(Domestic)        Car origin(Foreign)      
                                           mean    sd                 mean    sd
    string
    Repair record 1978(1)                 21.00  4.24                           
    Repair record 1978(2)                 19.13  3.76                           
    Repair record 1978(3)                 19.00  4.09                23.33  2.52
    Repair record 1978(4)                 18.44  4.59                24.89  2.71
    Repair record 1978(5)                 32.00  2.83                26.33  9.37
    ----------------------------------------------------------------------------
    
    matrix tbl = r(sumat)
    
    putdocx table tablename = matrix( tbl ), nformat(%6.2f) rownames colnames  
    
    putdocx save ejemplo.docx, replace
    Here You can see the putdocx table without categoric names: Domestic and Foreign
    Thanks in advance
    Rodrigo
    Click image for larger version

Name:	Sin título.png
Views:	1
Size:	23.4 KB
ID:	1687952

  • #2
    I changed my focus and used collect to make my table succesfully.

    Code:
    table (var rep78) (foreign result) , statistic(mean mpg ) statistic(sd mpg) nototal
    
    collect label levels result sd "SD", modify
    collect layout
    
    putdocx begin
    putdocx collect
    
    putdocx save ejemplo.docx, replace
    Result:
    Click image for larger version

Name:	Sin título.png
Views:	1
Size:	15.3 KB
ID:	1688059

    Last edited by Rodrigo Badilla; 04 Nov 2022, 08:56.

    Comment

    Working...
    X