Dear Statalisters,
I usually run the outreg2 command to export regression output to Word. Recently, I've been exploring the options of the putdocx command for saving results and output to Word files using codes similar to this one:
Creating this kind of code for all of the regressions that I have to run is not very user-friendly. However, the putdocx command has some interesting features that, as far as I know, cannot be included in the outreg2 command. For example, cells can be fitted to content in Word (see option layout(autofitcontents) in bold), text can be aligned to the right of a cell (see option: halign(right) in bold) and a table can be aligned to the center of the page (see option: halign(center) in bold). Does anyone know if and how to include these features in the outreg2 command?
Thank you in advance.
Kind regards,
Eline
I usually run the outreg2 command to export regression output to Word. Recently, I've been exploring the options of the putdocx command for saving results and output to Word files using codes similar to this one:
Code:
putdocx begin regress mpg gear_ratio turn foreign, noheader cformat(%9.3f) matrix list r(table) matrix rtable = r(table)' matrix r_table = rtable[1...,1], rtable[1...,5..6] putdocx table Example_Putdocx3 = (1,2), border(all, nil) width(4) halign(center) note("Note: standard errors are in parentheses") layout(autofitcontents) putdocx table Example_Putdocx3(1,1)=("mpg"), halign(right) colspan(2) border(top) border(bottom) local row 1 local vari 1 foreach x in gear_ratio turn foreign _cons { putdocx table Example_Putdocx3(`row',.), addrows(2) local b: display %9.3f rtable[`vari',1] local se: display %9.3f rtable[`vari',2] local ++vari local ++row putdocx table Example_Putdocx3(`row',1) = ("`x'"), halign(right) putdocx table Example_Putdocx3(`row',2) = ("`b'"), halign(right) local ++row local se = strtrim("`se'") putdocx table Example_Putdocx3(`row',2) = ("(`se')"), halign(right) } putdocx table Example_Putdocx3(`row',.), addrows(2) local ++row putdocx table Example_Putdocx3(`row',1) = ("N"), border(top) halign(right) putdocx table Example_Putdocx3(`row',2) = (e(N)), border(top) halign(right) local ++row local r2: display %9.3f e(r2) putdocx table Example_Putdocx3(`row',1) = ("R2"), halign(right) border(bottom) putdocx table Example_Putdocx3(`row',2) = (`r2'), halign(right) border(bottom) putdocx save Example_Putdocx.docx, append
Creating this kind of code for all of the regressions that I have to run is not very user-friendly. However, the putdocx command has some interesting features that, as far as I know, cannot be included in the outreg2 command. For example, cells can be fitted to content in Word (see option layout(autofitcontents) in bold), text can be aligned to the right of a cell (see option: halign(right) in bold) and a table can be aligned to the center of the page (see option: halign(center) in bold). Does anyone know if and how to include these features in the outreg2 command?
Thank you in advance.
Kind regards,
Eline
Comment