Stata is a statistical software package popular in the economics field.
Stata Markdown is a user-written package that allows one to use the code-editor (DO Editor) to combine text and code to create html/pdf output.
Start with a .stmd and open it. .stmd is the file format for “STATA markdown” and we provide a template that you can download here
Now move this file to a folder you created for your STATA assignment.
Let’s use a modified version of the Police Violence Data Source: Mapping Police Violence that documents victims of police violence. Download this example dataset and move it to your STATA assignment folder.
Open the Stata Markdown file .stmd. Change the path to the assignment folder where the markdown file and dataset reside.
cd "PATH NAME
cd "PATHNAME"
How to find the path
STATA Markdown uses code fences to denote code chunks. Each code chunk starts with ```{s} and ends with ```.
To load the data
use pviolence_example.dta, clear
To run a code chunk, highlight the chunk, and then select “DO”.
Let’s load this .csv file into STATA
import delimited "pviolence_example.csv", clear
histogram vicblack_per000, width(3)
graph export vicblack_per000.png, width(500) replace
Then to insert the .png histogram you will include the following OUTSIDE of the code block.

To create a final .html file that combines text, code, and results go to the Command line and type.
markstat using Stata_Markdown_example2
Example 2 .stmd file and .html output.
** Yes, there is a certain irony involved with writing a guide for Stata Markdown in R Markdown. Until Stata has a similar RPubs site, this is the way.