pyreadstat
Reads and Writes SAS, SPSS and Stata files into/from pandas and polars data frames.
What it is and what it does
Pyreadstat is a Python wrapper around the ReadStat C library that reads and writes SAS (sas7bdat, sas7bcat, xport), SPSS (sav, zsav, por), and Stata (dta) files into pandas and polars DataFrames. It addresses key limitations in pandas' native read_sas method: it preserves value labels from the original files, correctly distinguishes between date and datetime columns (rather than converting all to datetime), automatically handles character encoding via UTF-8 conversion, and offers significantly faster performance on large files.
The package supports reading file headers only for quick metadata inspection, reading selected columns, chunked reading, parallel multiprocess reading, and reading value labels separately. It also supports writing DataFrames back to these formats with options for value labels and user-defined missing values. The library is actively maintained, has no known security vulnerabilities, and is positioned as a Python equivalent to R's Haven package.
Use it for:
- Migrate legacy SAS datasets to pandas or polars for modern data analysis workflows without losing value labels or date precision.
- Quickly scan metadata from many SPSS or Stata files to identify datasets containing specific columns before full import.
- Read large SPSS files in parallel processes to reduce load time when processing multiple files or very large single files.
- Preserve and extract categorical value labels from SPSS or Stata files for reproducible statistical reporting.
- Convert between SAS, SPSS, and Stata formats by reading into a DataFrame and writing to a different format.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Reads and writes SAS, SPSS, and Stata data files directly into pandas and polars DataFrames, preserving value labels, dates, and encodings.
Yes. Pyreadstat is worth installing if you work with SAS, SPSS, or Stata files and need to load them into Python. It is actively maintained, has no known vulnerabilities, offers significantly better performance than pandas' native read_sas, and preserves metadata that other readers discard. Medium install friction is manageable via prebuilt wheels. The Apache-2.0 license is permissive. The only caveat is the package's own disclaimer that it is not validated for critical reporting tasks where data accuracy is legally mandated.
Install
pyreadstat on PyPI
pip
pip install pyreadstatuv
uv add pyreadstatpoetry
poetry add pyreadstatInstalling pyreadstat
Before you install
Medium install friction due to compiled C extensions; prebuilt wheels available for Python 3.10–3.13 on macOS (x86_64 and arm64), Linux (x86_64 and aarch64), and Windows. Active maintenance with a release 2 days old.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install pyreadstat
import pyreadstat
df, meta = pyreadstat.read_sas7bdat('file.sas7bdat')
# or for SPSS:
df, meta = pyreadstat.read_sav('file.sav')
# or for Stata:
df, meta = pyreadstat.read_dta('file.dta')
Requires a C compiler to build from source; prebuilt wheels simplify installation on common platforms. Either pandas or polars must be installed separately.
Verify before relying
- Whether the package handles all SAS catalog (.sas7bcat) file variations reliably in production environments.
- Performance characteristics when reading very large files with mixed data types on different platforms.
- Completeness of support for SPSS and Stata format extensions and edge cases not covered in the documentation.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 2 — narwhals, numpy |
| Maintenance | actively maintained — 2 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,443,951/month — #2,622 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyreadstat-1.3.6-cp310-cp310-macosx_10_9_x86_64.whl; pyreadstat-1.3.6-cp310-cp310-macosx_11_0_arm64.whl; pyreadstat-1.3.6-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; pyreadstat-1.3.6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; pyreadstat-1.3.6-cp310-cp310-win_amd64.whl; pyreadstat-1.3.6-cp311-cp311-macosx_10_9_x86_64.whl; pyreadstat-1.3.6-cp311-cp311-macosx_11_0_arm64.whl; pyreadstat-1.3.6-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; pyreadstat-1.3.6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; pyreadstat-1.3.6-cp311-cp311-win_amd64.whl; pyreadstat-1.3.6-cp312-cp312-macosx_10_13_x86_64.whl; pyreadstat-1.3.6-cp312-cp312-macosx_11_0_arm64.whl; pyreadstat-1.3.6-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; pyreadstat-1.3.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; pyreadstat-1.3.6-cp312-cp312-win_amd64.whl; pyreadstat-1.3.6-cp313-cp313-macosx_10_13_x86_64.whl; pyreadstat-1.3.6-cp313-cp313-macosx_11_0_arm64.whl; pyreadstat-1.3.6-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; pyreadstat-1.3.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; pyreadstat-1.3.6-cp313-cp313-win_amd64.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
pyreadrReads and writes R RData and Rds files directly…
agpl · top 15,000 on PyPI
sas7bdatReads SAS7BDAT files (SAS statistical software…
permissive · top 15,000 on PyPI
saspySASPy connects Python to SAS deployments (local…
permissive · top 15,000 on PyPI
datacompyDataComPy compares two DataFrames across…
permissive · top 5,000 on PyPI
great-tablesGreat Tables transforms Pandas or Polars…
permissive · top 15,000 on PyPI
pandas-read-xmlConverts XML files into pandas DataFrames, with…
permissive · top 15,000 on PyPI
fastparquetfastparquet reads and writes Apache Parquet…
permissive · top 5,000 on PyPI
gspread-dataframeConverts between Google Sheets worksheets and…
permissive · top 5,000 on PyPI
itablesRenders Pandas and Polars DataFrames as…
permissive · top 5,000 on PyPI