Dynamic Markdown Documents with Stata

Stata has the ability to process text documents written with unexecuted Stata code and Markdown formating, and produce HTML documents. Paired with Pandoc, this is also capable of producing Word and PDF documents.

Take for example the following document, "ttest example.stmd".


# Homework 5
#### Doug Hemken

Demonstrate a two-group t-test using Stata.  Illustrate with a box plot.

First, simulate some data.

```{stata}
clear
set obs 2
generate group = _n - 1
expand = 15
generate y = rnormal(group)
```

Let's check the data we created.

```{stata}
table group, contents(freq mean y sd y semean y) row
```

Next, do the t-test.

```{stata}
ttest y, by(group)
```

Finally, a box plot.

```{stata}
graph box y, by(group)
```

In Stata this may be processed with the following command

stmd "ttest example.stmd"

which produces a file named "ttest example.html". The contents of this file are included below.