Announcement

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

  • Fitting Large, Multidimensional Tables to a Word Document

    Hi all - hoping folks can help me manage a large multi-dimensional table that I need to output to a Word Document. (Yes, I agree with you, this is fundamentally a bad idea, but occasionally work requires such things.) The problem is that I have many groups, and would like to print them all to a single landscape table. I think the ideal thing would be to be able to rotate the column labels so they are vertical rather than horizontal, but that doesn't seem possible except with the LaTeX version of tabout, which has a rotate option. But I need to output these tables to word, so I'm wondering if there are other options available to me. I'm posting a toy example that produces the same problem below. Any advice would be welcome!

    Code:
    clear all 
    set seed 48103 
    set obs 22000
    
    gen u = runiform()
    egen group1 = cut(u), at(0 .01 .03 0.045 .2 .25 .35 .5 .52 .6 .72 .9 1) icodes 
    tab group1 
    
    gen group2 = runiformint(1, 3)
        label define grp2 1 "Group 1" 2 "Group 2" 3 "Group 3"
        label values group2 grp2
    gen group3 = runiformint(1, 7)
        label define grp3 1 "Group 1" 2 "Group 2" 3 "Group 3" 4 "Group 4" ///
                    5 "Group 5" 6 "Group 6" 7 "Group 7"
        label values group3 grp3
    
    table (group1) (group2 group3)
    
    collect style header cred_lvl control_peps_forcomb, title(hide)
    collect style cell border_block[column-header], valign(center) // Vertically align the column headers 
    collect layout 
    *Set Styling for Word
    collect style putdocx, halign(center) layout(autofitcontents) ///
        title("Test Table")
    putdocx begin, font(courier, 8) landscape // Open the document, format to courier 
    putdocx collect // Pull the table collection into the document 
    putdocx save "test_table.docx", replace // Save the document
Working...
X