HTML files with asdocx
To create HTML files with asdocx, we need to change the file extension to
.html in the save() option. Since the save() option is sticky, we do not have to write it in the subsequent runs of asdocx. The HTML tables and text follow the same generic syntax of asdocx. You may explore the asdocx examples tab from the left menu to see how different types of tables can be created with asdocx. Similarly, if you want to add text / paragraphs to the HTML document, follow this link for knowing different options. As a matter of fact, all tables on this page and elsewhere on this website are created with asdocx.
In this post, I am going to create an HTML report that contains text and tables. I am also going to show how Stata and asdocx commands can be highlighted just like syntax highlighting feature in a text editor. Table and syntax formatting are controlled with a
asdocx.css file, that can be downloaded from here.
1. Base case: Table of summary statistics
Add asdocx as a prefix to Stata command and add
.html to the file name inside the save() option. Let’s create a file of basic summary statistics and create
Report.html file. Option
replace will replace any existing file with this name. If option
replace is not used, a new table is added to the given file if the file already exists.
* Load example data sysuse auto, clear asdocx sum, save(Report.html) replace