Update more links
[worg.git] / org-contrib / babel / languages / ob-doc-stata.org
blob87a034dbdd0d5f9ce052601923d02d9975411aad
1 #+OPTIONS:    H:3 num:nil toc:2 \n:nil ::t |:t ^:{} -:t f:t *:t tex:t d:(HIDE) tags:not-in-toc
2 #+STARTUP:    align fold nodlcheck hidestars oddeven lognotestate hideblocks
3 #+SEQ_TODO:   TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
4 #+TAGS:       Write(w) Update(u) Fix(f) Check(c) noexport(n)
5 #+TITLE:      Stata Source Code Blocks in Org Mode
6 #+AUTHOR:     Ista Zahn
7 #+EMAIL:      istazahn@gmail.com
8 #+LANGUAGE:   en
9 #+HTML_LINK_UP:    index.html
10 #+HTML_LINK_HOME:  https://orgmode.org/worg/
11 #+EXCLUDE_TAGS: noexport
13 #+name: banner
14 #+begin_export html
15   <div id="subtitle" style="float: center; text-align: center;">
16   <p>
17   Org Mode support for <a href="http://stata.com">Stata</a>
18   </p>
19   </div>
20 #+end_export
22 * Template Checklist [10/12]                                       :noexport:
23   - [X] Revise #+TITLE:
24   - [X] Indicate #+AUTHOR:
25   - [X] Add #+EMAIL:
26   - [-] Revise banner source block [2/3]
27     - [X] Add link to a useful language web site
28     - [X] Replace "Language" with language name
29     - [ ] Find a suitable graphic and use it to link to the language
30       web site
31   - [X] Write an [[Introduction]]
32   - [X] Describe [[Requirements and Setup][Requirements and Setup]]
33   - [X] Replace "Language" with language name in [[Org Mode Features for Language Source Code Blocks][Org Mode Features for Language Source Code Blocks]]
34   - [X] Describe [[Header Arguments][Header Arguments]]
35   - [X] Describe support for [[Sessions]]
36   - [X] Describe [[Result Types][Result Types]]
37   - [ ] Describe [[Other]] differences from supported languages
38   - [X] Provide brief [[Examples of Use][Examples of Use]]
39 * Introduction
40 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. 
41 * Requirements and Setup
42 Stata source code blocks in Org Mode requires a working Stata installation, as well as the [[http://ess.r-project.org][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.
44 To configure your emacs org-mode to use Stata, you'll need to ensure
45 that =org-babel-load-languages= includes an entry for it.
46 Typically, =org-babel-load-languages= will contain many entries.  The
47 example below omits other languages.
49 #+begin_src emacs-lisp :tangle yes
50   (org-babel-do-load-languages
51    'org-babel-load-languages
52    '((stata . t)))
53 #+end_src
55 * Org Mode Features for Stata Source Code Blocks
56 ** Header Arguments
57 Stata code evaluation currently only works with the header argument =:results output=; this is the default setting for stata code blocks.
58 ** Sessions
59 Session mode is supported in stata, including named sessions. 
60 ** Result Types
61 Only =output= is supported.
63 * Examples of Use
64   - Hello World!
65 #+BEGIN_SRC stata :session *Stata* :eval no :exports both
66   disp "Hello world"
67 #+END_SRC
69 #+RESULTS:
70 : disp "Hello world"
71 : Hello world
73   - Fit a linear model
74 #+BEGIN_SRC stata :session *Stata* :eval no :exports both
75   webuse auto
76   regress mpg price
77 #+END_SRC
79 #+RESULTS:
80 #+begin_example
81 webuse auto
82 (1978 Automobile Data)
83 regress mpg price
85       Source |       SS       df       MS              Number of obs =      74
86 -------------+------------------------------           F(  1,    72) =   20.26
87        Model |  536.541807     1  536.541807           Prob > F      =  0.0000
88     Residual |  1906.91765    72  26.4849674           R-squared     =  0.2196
89 -------------+------------------------------           Adj R-squared =  0.2087
90        Total |  2443.45946    73  33.4720474           Root MSE      =  5.1464
92 ------------------------------------------------------------------------------
93          mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
94 -------------+----------------------------------------------------------------
95        price |  -.0009192   .0002042    -4.50   0.000    -.0013263   -.0005121
96        _cons |   26.96417   1.393952    19.34   0.000     24.18538    29.74297
97 ------------------------------------------------------------------------------
98 #+end_example