stmd
command in StataStata provides commands to turn Markdown documents into HTML, Word, or PDF documents. Additionally, there are commands to execute Stata commands embedded within text documents, returning the commands and adding their output to the document - for example, generating a Markdown document.
The stmd
adds to this facility by allowing users to write dynamic documents in standard dynamic Markdown style. Code to be executed is enclosed in a code fence with an information tag that includes the language of the dynamic code, and may also include options.
Stata code to be executed is included in a document within a fenced code block like the following:
```{stata, ... }
--- stata commands here ---
```
The stmd
command takes a text document, converts the dynamic code to Markdown, and then converts the Markdown to it's final HTML, Word, or PDF format.
stmd
In Stata, use
ssc describe stmd
and follow the links to install stmd
. This includes stmd2dyn
, dyn2do
, and a script to install menu items. If you don’t care about the menu items just try
ssc install stmd
Alternatively, use
net from https://www.ssc.wisc.edu/~hemken/Stataworkshops
You can also obtain the source code, including these web pages for extra documentation, from https://github.com/Hemken/stmd .
See help stmd
for details.
Basic use to process a document is
stmd example.stmd, saving(example.html) replace
or just
stmd example.stmd
(HTML is the default output.)
Conventional dynamic Markdown looks like the text in the first column, and is turned into a web document (HTML) that appears like the second column.
There are two main parts to this:
Markdown | Result |
---|---|
|
An Example FileSome preliminary text. A code block, evaluted:
In-line text: the mean weight is 3019.5 pounds. A list:
A graph:
More text. |