Closed fredericky123 closed 2 years ago
Context: this is presumably related to https://www.statalist.org/forums/forum/general-stata-discussion/general/1658467-can-we-set-estab-output-the-tables-for-rtf-with-landscape-view.
Landscape: esttab
does not provide formatting options for the document, but additional RTF commands can be added to the header using the substitute()
option. In the RFT header written by estadd
there is a line that reads \deflang1033\plain\fs24
; this is a good place to add the extra formatting commands. Example:
sysuse auto
reg price weight foreign
est sto m1
local hook "\deflang1033\plain\fs24"
local pfmt "\paperw15840\paperh12240\landscape" // US letter
esttab m1 m1 m1 using ~/exampleUS.rtf, replace wide ///
substitute("`hook'" "`hook'`pfmt'")
local pfmt "\paperw16834\paperh11909\landscape" // A4
esttab m1 m1 m1 using ~/exampleA4.rtf, replace wide ///
substitute("`hook'" "`hook'`pfmt'")
ben
(esttab
I mean, not estadd
)
By the way, any plans for the docx file output?
Not really, especially since we now have collect
, table
, and etable
in Stata 17. Of course, putdocx
could be used by estout
to write docx files (or putexcel
for xlsx and putpdf
for pdf). However, it would be quite some work to integrate such support into estout
and the code, which is already quite an organically grown mess, would get even messier.
At some point an attempt to integrate putdocx
and putpdf
into estout
has been made by someone else, but I failed to pick this up. I still feel bad about it, but I just couldn't bring myself to get involved with the added complexity.
A solution that seems manageable to me would be to add some subroutines to esttab
that first call estout
to write a plain text table including some special tags (e.g. for lines) to a tempfile and then translate this file to docx, xlsx, or pdf. Functionality would not be as extensive as in collect
, but at least the basics could be covered without too much effort.
Thanks, Ben!
Since we this solution is elegant, we may add an option (landscape) for rtf output in the future
Thanks so much for the new option! By the way, any plans for the docx file output?