Skip to main content

sas7bdat.py

This module will read sas7bdat files using pure Python (2.6+, 3+). 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:

#!python
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:

#!python
df = f.to_data_frame()

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sas7bdat-2.1.2.tar.gz (15.7 kB view details)

Uploaded Source

File details

Details for the file sas7bdat-2.1.2.tar.gz.

File metadata

  • Download URL: sas7bdat-2.1.2.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.10.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.19.7 CPython/2.7.14

File hashes

Hashes for sas7bdat-2.1.2.tar.gz
Algorithm Hash digest
SHA256 6f11f8a812f860d27efa418a9b981d2f825466b973f750a15cc3ada57c0c46c6
MD5 4d48668cfdd9239087db4e188d92eb80
BLAKE2b-256 e370d1094303eb45b0087d74e8107a26bd280a2e3adb04cd15cf7a6f76cb4ca7

See more details on using hashes here.

Release history Release notifications | RSS feed

2.3.0

2 files

2.2.3

1 file

2.2.2

1 file

2.2.1

1 file

2.2.0

1 file

This release

2.1.2 This release

1 file

2.1.1

1 file

2.0.7

1 file

2.0.6

1 file

2.0.5

1 file

2.0.4

1 file

2.0.3

1 file

2.0.2

1 file

2.0.1

1 file

2.0.0

1 file

1.0.5

1 file

1.0.4

1 file

1.0.3

1 file

1.0.2

1 file

1.0.1

1 file

1.0.0

1 file

0.2.5

1 file

0.2.4

1 file

0.2.3

1 file

0.2.2

1 file

0.2.1

1 file

0.2.0

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

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