Skip to main content

sas7bdat.py

This module will read sas7bdat files using pure Python (2.7+). No SAS software required! The module started out as a port of the R script of the same name found here: <https://github.com/BioStatMatt/sas7bdat> but has since been completely rewritten.

Also included with this library is a simple command line script, sas7bdat_to_csv, which converts sas7bdat files to csv files. It will also print out header information and meta data using the –header option and it will batch convert files as well. Use the –help option for more information.

As is, I’ve successfully tested the script almost three hundred sample files I found on the internet. For the most part, it works well. We can now read compressed files!

I’m sure there are more issues that I haven’t come across yet. Please let me know if you come across a data file that isn’t supported and I’ll see if I can add support for the file.

Usage

To create a sas7bdat object, simply pass the constructor a file path. The object is iterable so you can read the contents like this:

from sas7bdat import SAS7BDAT
with SAS7BDAT('foo.sas7bdat') as f:
    for row in f:
        print row

The values in each row will be a string, float, datetime.date, datetime.datetime, or datetime.time instance.

If you’d like to get a pandas DataFrame, use the to_data_frame method:

df = f.to_data_frame()

Metadata

Release files for sas7bdat 1.0.1

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

Source distribution (sdist)

Source distribution for sas7bdat 1.0.1
File Size Uploaded Provenance Actions
sas7bdat-1.0.1.tar.gz 12.5 kB Without provenance Details for sas7bdat-1.0.1.tar.gz

Release files / sas7bdat-1.0.1.tar.gz

Download URL sas7bdat-1.0.1.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
52a5601b27074a74a3e983813f28823ceb605e6594b9730d4d5103d86ae6a0da
BLAKE2b-256 checksum
How to use checksums
816b7687dc80b39d1eed7a0b4a9f2b6837454f6f028e82dc2706e0d7208599ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for sas7bdat 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

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