Use the Stata Jupyter kernel with Atom's Hydrogen package to show Stata results inline. It works with Windows, macOS, and Linux.
Jul 14, 2014 Adding an indent to a normal Markdown file would be interpreted as a 'code block' in HTML. In Stata, this interpretation has been ignored. Stata packages that can interpret Markdown codes, Ketchup and MarkDoc both ignore this interpretation and remove indents, unless indents are used to style braces, where indents improve readability of the code.
Example uses the Atom Material Syntax theme and Fira Code font.
This package highlights:
9 Stata Help in Markdown 9.1 Introduction For some Stata documentation, you may want to include portions of Stata's help files. When I present workshops on Stata programming topics, I. Stata Markdown and Reproducible Research Author: Rob Hicks Created Date: 8/30/2020 12:30:48 PM.
`: .. '
as well as after local lname:
regexr()
and regexm()
functions, as well as the vastly expanded regex syntax provided in Stata 14 and 15 through the ustrregexm()
, ustrregexrf()
, and ustrregexra()
functions.Other nice features:
odbc
command. (The language-sql
base package must be active.)@Note
)To install, do one of the following:
language-stata
apm install language-stata
The local macro back tick autocompletion won't function until you fully restart Atom. Do ctrl-shift-P
or cmd-shift-P
to bring up the command palette, type Window: Reload
, and click enter.
Atom allows you to toggle whether a line is commented using ctrl+/. As of version 1.6.5, the comment character this uses is //
by default. You can change this to use /* */
or *
characters to comment lines.
To change to /* */
comments, you can put the following in your config.cson
file.
To change to *
comments, use the following. However I don't recommend using this character1.
Note that in your config.cson
file there can only be a single '.source.stata'
top-level key, and only a single editor
key under '.source.stata'
. If you customize some other settings within the Stata grammar, you might already have a '.source.stata'
key, and thus you would add the commentStart
key to it.
There are three ways to run code in Stata from Atom
The Hydrogen package in conjunction with the Stata Jupyter kernel shows Stata results inside Atom next to your code. The gif at the top of the page is an example of this setup. A few features:
stata-exec
.#delimit ;
interactively with your codeYou'll need to have both Hydrogen and stata_kernel
Interval sans pro font free download. installed. You caninstall Hydrogen from the Atom settings pane; see the stata_kernel
documentation for moreinformation on how to install stata_kernel
.
The stata-exec
package sends selected Stata code to an open Stata GUI window on Windows, macOS, and Linux. This differs from Hydrogen because it allows you to still interact with the Stata GUI. This might be easier for users who are new to Stata. However, it can be difficult to successfully install this on Windows.
The script package will run code in the Stata console, but has the limitations 1) each command is run in a separate session of Stata, 2) it currently doesn't work with selections; you have to run the entire file, 3) it doesn't work on Windows.
Stata 15 brought new features for working with dynamic documents. The dyndoc
command lets you write in Markdown and converts your file and code to HTML for viewing in a web browser.
It also added the dyntext
command, which fills in Stata output for any text file, without touching the text itself. This lets you then use third-party document generators like Pandoc and LaTeX to generate documents.
This package provides syntax highlighting for Stata code written inside Stata's dynamic tags for Markdown and LaTeX documents.
By default, this package's Markdown and LaTeX syntax highlighting will be applied for files ending in .domd
and .dotex
respectively. The language-markdown and language-latex packages must be installed for the highlighting to work.
If you name your file with a different extension, you can manually set the highlighting by clicking on the 'Plain Text' button on the bottom right of the screen (or by pressing CTRL+SHIFT+L). Then type stata
and you'll see a list of choices:For a .do
file, choose source.stata
; for a Markdown dynamic document choose source.dyndoc.md.stata
; and for a LaTeX dynamic document choose source.dyndoc.latex.stata
.
Both Hydrogen and stata-exec
should work for running code interactively, even within a dynamic document.
An example of the PDF output of using dyntext
and Pandoc is in the examples folder: dyntext.pdf
.
That file was created by running
from inside Stata 15, and then with
on the command line using Pandoc.
The file dyntext.dotex
is a proof-of-concept and should compile with LaTeX but the output is not shown here.
If you use the user-created commandwebdoc, you canadd highlighting by using a .dowd
file extension or by manually selecting thelanguage of the current file to be 'Stata Webdoc'.
1: The following code is legal Stata code, but Atom will confuse the *
used as multiplication with the *
used for a comment. So if your cursor is on the second line and you press ctrl+/, Atom will remove the *
symbol and the semantic meaning of the multiplication will be lost. Thus using //
as the comment symbol is safer.
The markstat command lets you combine Stata code with Markdown annotations to produce dynamic documents in HTML, PDF or DOCX format. |
Use Stata's code editor to write a script like fuel.stmd
above center, and then run markstat using fuel
to produce the web page on the left. Add the pdf
option to produce the PDF document on the top right. Or use the docx
option to produce the Word document on the bottom right, also discussed here. All from the same script! Requires Stata 14. A comparison with the new tools in Stata 15 is here. New: R code, see example here.
The markstat command also lets you combine Stata code with Markdown annotations to produce dynamic presentations in HTML or PDF format. |
Use Stata's code editor to write a script like deck.stmd
on the left, run markstat using deck, slides(santiago)
to produce an HTML presentation using S5 with the Santiago theme, as shown on the second slide on the top right. (The first slide shows the default Spiral theme.) Alternatively, change the option to beamer(madrid)
to generate a PDF slide show using Beamer with the Madrid theme (or any of many available), as shown on the second slide on the bottom right. (The first slide shows the default Beamer theme.) More on slides here.
Getting Started | Documentation | Examples |