.sas7bdat and .xpt files

SAS keeps datasets in .sas7bdat files and exchanges them as .xpt transport files. Both can be read without SAS.

What is a .sas7bdat file?

A .sas7bdat file is one dataset from a SAS library: rows, variables, variable labels and the name of the format each variable is displayed with. The format itself, such as "1 = Yes, 2 = No", lives in a separate catalog file (.sas7bcat), so a dataset on its own only carries the codes. SAS never published the .sas7bdat layout; other programs read it through reverse-engineered code.

The .xpt transport format (SAS XPORT) is the opposite: openly documented and meant for exchange. Version 5 limits variable names to 8 characters and is what the US FDA asks for in study data submissions, so clinical SDTM and ADaM datasets travel as .xpt. Public datasets such as NHANES are published in it too.

Banks, insurers, pharma companies and statistics agencies run on SAS, and their datasets regularly land with people who use R, Python or Excel instead.

Converters for .sas7bdat files

How to open a .sas7bdat file

With SAS, assign a library and read the dataset; transport files go through PROC CIMPORT, PROC COPY or the XPORT engine depending on how they were made. Without SAS, Python's pandas.read_sas reads both formats, and R has read_sas and read_xpt in the haven package.

In the browser: SAS7BDAT to CSV and XPT to CSV turn a dataset into CSV or an Excel workbook, with variable labels in a separate table and dates written as real dates. Nothing is uploaded. Coded variables stay numeric, because the formats catalog isn't read.

Questions about this format

Can I open a .sas7bdat file in Excel?

Not directly. Convert it to XLSX or CSV first; for very large datasets CSV is the safer choice.

What is the .sas7bcat file that came with my data?

The formats catalog: it holds the labels for coded values. It isn't data itself, and outside SAS only a few tools can read it.

Last updated: