Export flexmat file with asdocx to Word, Excel, or LaTeX
flexmat program is an ideal tool for creating customized tables. In this post, I show how table title, table body, and table notes can be created in flexmat and then exported to with asdocx.
Setting the file name
The flexmat program first searches the memory for the file name that users might have specified the save() option of asdocx. If flexmat is used before asdocx in a Stata session, it will then use the default file name of Myfile.docx. However, if a user wants to use a different file name when she exports the output with asdocx, the file name must be set using the
asdocx setfile sub-command with
save() option. Say the user would like to set the file name as Table X : Multivariate regression for all countries.docx, then”
asdocx setfile, save(Table X : Multivariate regression for all countries.docx)
In case we wish to send the output to an Excel file, then we would change the file extension to
save(able X : Multivariate regression for all countries.xlsx).
We can also use other options of asdocx when setting the file name, e.g.,
font(font_name) to change the font family or
fs(#) to set the font size of the document [see other options here].
asdocx setfile, save(Table X : Multivariate regression for all countries.docx) font(Arial)
Table title and notes
Table tile and notes are set from flexmat using `addparts` sub-command with `title()` and `notes()` option. See the following example:
flexmat addparts, title(Table X : Multivariate regression for all countries.docx) /// notes(Sample is from 1990-2021)
Export with asdocx
Once the flexmat file is ready, it can be then exported to any of the asdocx’s supported formats, that include MS Word, Excel, or LaTeX. Following is the asdocx syntax for exporting flexmat files.