You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Jupyter notebook allows you to combine interactive code and results
with Markdown in
a single document. Though it is named after the three core programming
languages it supports (Julia, Python, and R), it can be used with with a
wide variety of languages.
nbstata allows you to create Stata notebooks (as opposed to using
Stata within a Python
notebook,
which is needlessly clunky if you are working primarily with Stata).
Users of Stata 17 or 18.0 also get these features only built-in natively
to Stata 18.5+:
Displays Stata output without the redundant ‘echo’ of (multi-line)
commands
Autocompletion for variables, macros, matrices, and file paths
Interactive/richtext help files accessible within notebook
#delimit ; interactive support (along with all types of comments)
The video below demonstrates using Stata in a Jupyter notebook. In
addition to the
NBClassic
application shown there, nbstata can also be used with
JupyterLab,
VS
Code,
or Quarto.
nbstata is being developed using
nbdev.
The /nbs directory is where edits to the source code should be made.
(The python code is then exported to the /nbdev library folder.)
Kyle Barron authored the original stata_kernel, which works for older
versions of Stata. Vinci Chow created a Stata kernel that instead uses
pystata, which first became
available with Stata 17. nbstata was originally derived from his
pystata-kernel, but much
of the docs and newer features are derived from stata_kernel.
Footnotes
Stata dynamic
documents
can do this part, though with a less interactive workflow. (See
also: markstat,
stmd,
and
Statamarkdown)
Using nbstata with
Quarto
instead gives you a similar workflow, with greater flexibility of
output. ↩