Options for docx (Word) files
asdocx uses asdocx_defaults.ado file to set options permanently. For more details on this, please visit this section. In this section, we are going to understand how to change various formatting options for the current session. Once set, these options are sticky and will be used by asdocx until Stata is restarted or the option is set to a different value.
The default file file name is
MyFile.docx. However, this can be changed using the
save(file_name.ext) option. So, let say we wish to save the file as
Panel Data Regression, where y x1 x2 x3 are variables in our dataset, our regression code will be:
asdocx reg y x1 x2 x3, save(Panel Data Regression) replace
.docx is the default, we can skip it from the file name to save some typing. However, the following code also works. Please note the
.docx addition to the file name. If we were to send the results to MS Excel, then typing
.xlsx is must.
asdocx reg y x1 x2 x3, save(Panel Data Regression.docx) replace
The default behavior of asdocx is to append tables and contents to the existing file, therefore, option append is option. Option replace is used to replace any existing file.
The default font size is 12 points. This can be changed to any desired value using the
fs(#) option. Therefore, to set the font size as 14 pt, the code would be
asdocx sum, replace fs(14)
The default font family is Garamond. Fonts for the entire document can be set using option
dfont(fontname). Fonts for individual items such as table or text can be set using the
fontname may be any valid font installed on the user’s computer. Let say we wish to change the document font to
Calibri and the current table font to
Arial, the code would be:
asdocx sum, replace font(Arial) dfont(Calibri)
The default is to report three decimal points. This can be changed using the
dec(#) option. The following code reports 4 decimal points:
asdocx sum, replace dec(4)
The default layout is
portrait. To change document orientation to
* Use landscape orientation
asdocx sum, replace
* Change back to Portrait asdocx sum, replace portrait
The possible values for paper are letter, legal, A3, A4, and B4JIS. The default paper size is
A4, to change it to legal, use option
asdocx sum, paper(Legal)
The table layout can be
auto. The default is
fixed layout sets the same width for all columns in the table. It is similar to the Fixed-Column Width in MS Word. When
auto is specified, the column width automatically resizes to fit the window. It is similar to ‘AutoFit-Window‘ in MS Word. When
autofit is specified, the table width is determined by the overall table layout algorithm, which automatically resizes the column width to fit the contents. In MS Word parlance, it is similar to ‘AutoFit-Contents‘. For tables with many columns, it is recommended to use the
auto option. One example could be to report the detailed summary statistics using
autofit option. To set the table layout to
asdocx sum, detail table_layout(autofit)
Table title is set using the
title(title text) option. Therefore, if the desired table title is
Table 5: Descriptive Statistics, the code would be:
asdocx sum, detail title(Table 5: Descriptive Statistics)
9.2 Table Title : Font Size
To set the table title font size, use option fs_title(#).
asdocx sum, title(Summary) fs_title(18) replace
9.3 Table Title : Bold
The table title is bold by default. To use normal font face, use option title_bold(0) or title_bold(1) to use bold face again.
asdocx sum, title(Summary) title_bold(1) replace
9.4 Table Title : Italic
To make the table title italic, use option title_italic(1)
asdocx sum, title(Summary) title_italic(1) replace
To set the table alignment, use option
table_align(). The possible values for this option are left, right, and center. Note that setting the table alignment has no visible effect if the table has the default width.
* Set the table align to left
asdocx sum, detail
Page breaks can be added with the option
pagebreak(before) inserts a page break before a given table.
pagebreak(after) inserts a page break after the table.