Adding text

We can write text to our output file with option text(text lines). This is useful when we want to add details or comments with the Stata output. In fact, this option makes asdocx really flexible in terms of adding tables and paragraph at the same time. We never have to leave the Stata interface to add comments or interpretation with the results.

Control Words

The following control words are used to set text formatting properties.
1. \b : If a sentence contains \b, it will be shown in bold. However, this option is not sticky. So, new lines will be shown in regular font face.

2. \i : To show text in italic. This option is not sticky. So, new lines will be shown in regular font face.

3. \par : To start a new paragraph

4. \super : Show text in super-script, e.g

asdocx, text(The R\super2 is 0.25)

will be shown as The R2 is 0.25

5. \sub : Show text in sub-script, e.g

asdocx, text(The B\sub1 is 0.98)

will be shown as The B1 is 0.98


Options are written outside the brackets of the text(). The following options can be used to format the given text.

1. h1 or heading1: Either h1 or heading1 is used to make the current line as heading 1. Similarly, h2 or heading1 , h3 or heading3h9 or heading9 can be used.

2. title : option title is used to make the current line as document title.

3. fs() to set font size : 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, text(This is my new text line) fs(14)

4. Font family : The default font family is Garamond. This can be changed using the font(fontname) option. fontname may be any valid font installed on the user’s computer. Let say we wish to change the font family to Arial, the code would be:

asdocx, text(Yet another line) font(Arial)

5. Page breaks
Page breaks can be added with the option  pagebreak(before) or pagebreak(after)pagebreak(before) inserts a page break before a given table. pagebreak(after) inserts a page break after the table.

6. linebreak : adds a typical line break. New text restarts on the next line.

Consider the following examples:

* Start a new document and write title
asdocx, text("Panel Data Analysis") title replace

* Write some text with font size of 18pt
asdocx, text("Results and Summary Statistics.") fs(18)

* Add bold text and keep font size at 12pt
asdocx, text("\b I a am bold item. ") fs(12)

* Change font size to 14pt
asdocx, text("This section of the report will present the results and analysis.")  fs(14)

* Add italic text. Text can added without quotes
asdocx, text(\i Notes to the tables are reported in table notes.)

* Revert back to normal text
asdocx, text(" Significance level is reported with *, **, ***. ")

* Add super-script
asdocx, text("The R\super2 of the model is 0.0764.")

* Add subscript
asdocx, text("The coefficient B\sub1 indicates a positive ...")

The output from the above codes is given below.
asdocx text stata

The convenience trick

It may be inconvenient to type asdocx, text() each time a text line is written. One can write the asdocx, text( to a local or global macro and then add that macro to the beginning of the text line. However, this still does not eliminate the discomfort of closing the brackets at the end of each text line. But we do not have to worry as asdocx insects each text command for the closing bracket. When not available, it then adds the closing bracket to the end of the line. One caveat is that we cannot add any option when using this trick. This is because the bracket is added to the end of the line, which makes everything part of the text, including any option that we may add with the text command. Therefore, when options must be added, we have to write the full text command in conventional way. See example 2 below:

Example Reports : Text, results and graphs 

Example 1 : Download the Do File | Download the output file

Example 2 : Using convenience trick | Download the output file