Adding text


The option ‘text(text lines)’ allows us to include text in our output file. This feature is particularly useful when we want to add additional details or comments to accompany the Stata output. In fact, this option makes asdocx highly versatile in terms of adding tables and paragraphs simultaneously. We never need to leave the Stata interface to include comments or interpret 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


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 can be tedious to type asdocx, text() each time you want to add a text line. To make this process easier, you can save asdocx, text( to a local or global macro and then include that macro at the beginning of the text line. However, this does not completely eliminate the need to close the brackets at the end of each text line. Thankfully, asdocx automatically checks each text command for the closing bracket and will add it if it is missing. One limitation to keep in mind is that this method does not allow you to include options. This is because the bracket is added to the end of the line, making everything part of the text, including any options that may have been added to the text command. To add options, you must write the full text command in a conventional way, as you can see in example 2.

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