A Jupyter kernel for Stata based on the xeus framework.
xeus-stata is a native C++ implementation of a Jupyter kernel for the Stata statistical software, built on the xeus framework. Unlike Python-based kernels, xeus-stata provides native performance and tight integration with the Jupyter ecosystem.
- Code Execution: Run Stata commands interactively in Jupyter notebooks
- Code Completion: Intelligent completion for commands, variables, and functions
- Code Inspection: Access Stata help and documentation inline
- Graph Display: Automatic detection and display of Stata graphs
- Error Handling: Clear error messages with Stata error codes
- Cross-Platform: Supports Linux, macOS, and Windows
- A licensed installation of Stata (version 14 or later recommended)
- CMake 3.8 or later
- C++17 compatible compiler
- Jupyter or JupyterLab
mamba install -c conda-forge xeus-stata# Clone the repository
git clone https://github.com/jupyter-xeus/xeus-stata.git
cd xeus-stata
# Create a build directory
mkdir build && cd build
# Configure with CMake
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
# Build
make -j$(nproc)
# Install
make install
# Register the kernel
jupyter kernelspec install ../share/jupyter/kernels/xeus-stata --sys-prefixAfter installation, you can use xeus-stata in Jupyter:
# Launch Jupyter Lab
jupyter lab
# Or Jupyter Notebook
jupyter notebookThen create a new notebook and select "Stata" as the kernel.
* Load example dataset
sysuse auto, clear
* Summary statistics
summarize price mpg weight
* Create a scatter plot
scatter mpg weight
* Run regression
regress price mpg weight foreignxeus-stata will automatically detect Stata if it's installed in a standard location. If Stata is installed in a non-standard location, set the STATA_PATH environment variable:
export STATA_PATH="/path/to/stata"xeus-stata is currently in early development. Current status:
- Basic project structure
- Console mode Stata interface (Linux/macOS)
- Graph display integration (SVG/PNG)
- HTML table output formatting
- Windows console mode support
- Complete code completion
- Complete code inspection
- Comprehensive testing
- Documentation
xeus-stata consists of several key components:
- xinterpreter: Implements the Jupyter kernel protocol via xeus
- stata_session: Manages the Stata process and communication
- stata_parser: Parses Stata output for results, errors, and graphs
- completion: Provides code completion functionality
- inspection: Provides code inspection and help
| Feature | xeus-stata | stata_kernel |
|---|---|---|
| Language | C++ | Python |
| Performance | Native | Python overhead |
| Dependencies | C++ libraries | Python + packages |
| License | BSD-3-Clause | GPL-3.0 |
| Widget Support | xwidgets (planned) | Limited |
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
# Create development environment
mamba create -n xeus-stata-dev -c conda-forge \
xeus xeus-zmq xtl nlohmann_json cppzmq \
cmake gtest ninja jupyterlab cxx-compiler
conda activate xeus-stata-dev
# Build in debug mode
mkdir build-debug && cd build-debug
cmake .. -DCMAKE_BUILD_TYPE=Debug
make -j$(nproc)xeus-stata is licensed under the BSD-3-Clause license. See LICENSE for details.
- xeus - The underlying kernel framework
- stata_kernel - Inspiration and reference implementation
- The Jupyter project
- Documentation: https://xeus-stata.readthedocs.io (coming soon)
- Source Code: https://github.com/jupyter-xeus/xeus-stata
- Issue Tracker: https://github.com/jupyter-xeus/xeus-stata/issues
- Stata: https://www.stata.com