Skip to main content

nbstata: a new Stata kernel

 

nbstata is a Jupyter kernel for Stata built on top of pystata.

For the User Guide, click here.

 

What is Jupyter?

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).

Key nbstata features

  • Easy setup
  • Works with Stata 17+ (only).
  • DataGrid widget with browse-like capabilities (e.g., interactive filtering)
  • Variable and data properties available in a ‘contextual help’ side panel
  • Quarto inline code support

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.

Animated GIF demoing major Stata kernel features

What can you do with Stata notebooks…

…that you can’t do with the official Stata interface?

  • Exploratory analysis that is both:
    • interactive
    • preserved for future reference/editing
  • Present results in a way that interweaves:1
    • code
    • results (including graphs)
    • rich text:
      1. lists
      2. Headings
      3. WordArt of the word 'images'
      4. links
      5. math: $y_{it}=\beta_0+\varepsilon_{it}$

Contributing

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.)

For more, see CONTRIBUTING.md.

Acknowledgements

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.

  1. 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. ↩

Metadata

Release files for nbstata 0.8.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nbstata 0.8.7
File Size Uploaded
nbstata-0.8.7.tar.gz 187.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nbstata 0.8.7
File Interpreter ABI Platform
nbstata-0.8.7-py3-none-any.whl Python 3 none any Details

Total release size: 314.0 kB

Release files / nbstata-0.8.7.tar.gz

Download URL nbstata-0.8.7.tar.gz
Size 187.2 kB
Tags Source
SHA-256 checksum
How to use checksums
305e03d85bfbf2b5aa0ddbbb319be33705a664c3a5b8aa2e620e1d38ea55aa16
BLAKE2b-256 checksum
How to use checksums
c8ba7725bc9c1f5bc96083e0fed2e4e83a6d76d9cbae4b173ebf36289cd53d51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / nbstata-0.8.7-py3-none-any.whl

Download URL nbstata-0.8.7-py3-none-any.whl
Size 126.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8097bf0a255a1eda1524b2832fcb6c1810d58dc95c6e27badb72b6983273787d
BLAKE2b-256 checksum
How to use checksums
d22e4b44a743c3baa99510902fac02749a983b2c1b94b27eed9d49bd608f0c03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

0.8.7 This release

2 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page