benjann / estout

Stata module to make regression tables
http://repec.sowi.unibe.ch/stata/estout/index.html
MIT License
70 stars 17 forks source link

how to output results by group to a rtf file? #59

Open yanyu2015 opened 1 year ago

yanyu2015 commented 1 year ago

The following example can output results perfectly in grouped form to a LaTeX file.

sysuse auto, clear
eststo clear
eststo: quietly reg weight mpg
eststo: quietly reg weight mpg foreign
eststo: quietly reg price weight mpg
eststo: quietly reg price weight mpg foreign

esttab using mgroups2.tex, replace                        ///
       star(* 0.1 ** 0.05 *** 0.01)                       ///
       mgroups(A B,                                       ///
               pattern(1 0 1 0) span                      ///
               prefix(\multicolumn{@span}{c}{) suffix(})  ///
               erepeat(\cmidrule(lr){@span}))             ///
       page booktabs

However, if I want to achieve a similar Panel A / Panel B effect when outputting to an RTF file, is this possible? If so, can you give an example?

NilsEnevoldsen commented 1 year ago

This thread might have some guidance. Looks tricky. Would be good to know if there's a better way. https://www.stata.com/statalist/archive/2012-11/msg01157.html

yanyu2015 commented 1 year ago

Thank you! that string of characters is hard to understand, a similar method is

esttab using mgroups3.rtf, replace                        ///
       star(* 0.1 ** 0.05 *** 0.01)                       ///
       mgroups("A" "B",                                   ///    
               pattern(1 0 1 0)) ///
       extracols(3)

But I don't know how to reduce the column width of this new inserted column alone, and underline the "A" and "B" cells.

benjann commented 1 year ago

I think the problem is that RTF has no support for merged cells (but I might be mistaken).

benjann commented 1 year ago

I would just do

esttab using mgroups2.rtf, replace mgroups(A B, pattern(1 0 1 0))

and then manually merge the cells in Word. If you are looking for a fully automated solution this would not be an option, of course...

yanyu2015 commented 1 year ago

What about .xlsx? Is it only LaTeX that can fully implement the above functions?