Stata Source Code Blocks in Org Mode
Org Mode support for Stata
Introduction
Stata is a proprietary statistics program popular in economics and some social sciences. Stata code blocks are partially supported in Org Mode. Basic code evaluation works, but there is no support for graphics or other more advanced org-babel features.
Requirements and Setup
Stata source code blocks in Org Mode requires a working Stata installation, as well as the ESS emacs package. Before configuring Org Mode to evaluate Stata source code blocks you should make sure that ESS is configured correctly, and that you can evaluate Stata code in ESS.
To configure your emacs org-mode to use Stata, you'll need to ensure
that org-babel-load-languages
includes an entry for it.
Typically, org-babel-load-languages
will contain many entries. The
example below omits other languages.
(org-babel-do-load-languages 'org-babel-load-languages '((stata . t)))
Org Mode Features for Stata Source Code Blocks
Header Arguments
Stata code evaluation currently only works with the header argument :results output
; this is the default setting for stata code blocks.
Sessions
Session mode is supported in stata, including named sessions.
Result Types
Only output
is supported.
Examples of Use
- Hello World!
disp "Hello world"
disp "Hello world" Hello world
- Fit a linear model
webuse auto regress mpg price
webuse auto (1978 Automobile Data) regress mpg price Source | SS df MS Number of obs = 74 -------------+------------------------------ F( 1, 72) = 20.26 Model | 536.541807 1 536.541807 Prob > F = 0.0000 Residual | 1906.91765 72 26.4849674 R-squared = 0.2196 -------------+------------------------------ Adj R-squared = 0.2087 Total | 2443.45946 73 33.4720474 Root MSE = 5.1464 ------------------------------------------------------------------------------ mpg | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- price | -.0009192 .0002042 -4.50 0.000 -.0013263 -.0005121 _cons | 26.96417 1.393952 19.34 0.000 24.18538 29.74297 ------------------------------------------------------------------------------