Simple example script using fenced code blocks

Let us read the fuel efficiency data that is shipped with Stata

. sysuse auto, clear
(1978 Automobile Data)

To study how fuel efficiency depends on weight it is useful to transform the dependent variable from “miles per gallon” to “gallons per 100 miles”

. gen gphm = 100/mpg

We then obtain a more linear relationship

. twoway scatter gphm weight || lfit gphm weight ///
> , ytitle(Gallons per Mile) legend(off)

. graph export auto.png, width(500) replace
(file auto.png written in PNG format)

. 
Fuel Efficiency
Fuel Efficiency

That’s all for now!

Command to knit into .html

markstat using test, strict

The norun info string will prevent -markstat- from running the command above when knitting. Without norun, you will hit an infinite loop. Even though -markstat- ignores this, you can still run the line through Atom using stata-exec’s “Run” command (mapped to cmd-enter in my case). This makes it convenient to re-knit the document directly from Atom.