An introduction to using Markdown in Stata

Lauren Samuels, lauren.samuels@vumc.org

26 May 2020


Things to include at the top of every file

In general, I would recommend having these things be the first two lines of your file.

First, specify the minimum required version of dyndoc.

<<dd_version: 2>>

From the Stata Reporting manual:

The dd version tag specifies the minimum version required to convert the source file. The version number is independent of Stata’s version command… The current version, and the default, is 2, and it is introduced as of the release of Stata 16. The current version number is also stored in c(dyndoc version).

Then, specify any overall stylistic elements for the report.

<<dd_include: header.txt >>

If there are stylistic elements you want to use in all your reports, you might want to store them in a header file that you can use across projects.

Stata’s standard header file can be found at http://www.stata-press.com/data/r16/reporting/header.txt.

The header file specifies a particular css (cascading style sheet).


Now you can continue with the rest of your file

Markdown is designed to be easy to learn and use. You can find a “cheat sheet” at Markdown Cheat Sheet, and a more detailed description of the basic syntax and best practices at Basic Syntax.

Note that there are several “flavors” of Markdown out there, so if you try something from the Markdown Guide and it doesn’t work in Stata, don’t give up. Many of the differences in “flavors” have to do with spaces surrounding symbols and/or blank lines preceding or following text, so fiddling with those things can be helpful if you’re having problems.