15.8 Run Stata code
You can run Stata (https://www.stata.com) code with the stata
engine if you have installed Stata. Unless the stata
executable can be found via the environment variable PATH
, you need to specify the full path to the executable via the chunk option engine.path
, e.g., engine.path = "C:/Program Files (x86)/Stata15/StataSE-64.exe"
. The following is a quick example:
```{stata}
sysuse auto
summarize
```
The stata
engine in knitr is quite limited. Doug Hemken has substantially extended it in the Statamarkdown package, which is available on GitHub at https://github.com/Hemken/Statamarkdown. You may find tutorials about this package by searching online for “Stata R Markdown.”