Install & Compatibility
Where this runs
tested against v5.107.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.170s · 30.1MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 2.2s · import 0.154s · 31MB
28MB installed
● package 28MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SASsession
✓ from saspy import SASsession
✗ import saspy
sas = saspy.SASsession()
This quickstart demonstrates how to establish a connection to a SAS session, submit arbitrary SAS code, and exchange data between a pandas DataFrame and a SAS dataset. It highlights the importance of the `sascfg_personal.py` configuration file for defining SAS connection details.
import saspy
import pandas as pd
import os
# NOTE: SASPy requires a configuration file (sascfg_personal.py) to define connection details.
# This file is typically located in your Python site-packages/saspy directory or ~/.config/saspy/.
# For example, using a 'winlocal' configuration (defined in sascfg_personal.py):
# sas = saspy.SASsession(cfgname='winlocal')
# If only one configuration is defined, or if running in an interactive environment that supports prompts:
sas = saspy.SASsession()
print(f"SAS Connection established: {sas.SASsessionid}")
# Example: Submit SAS code and get results
result = sas.submit("proc print data=sashelp.class(obs=5); run;")
print("SAS Log:\n", result['LOG'])
print("SAS Listing:\n", result['LST'])
# Example: Transfer a pandas DataFrame to SAS
data_df = pd.DataFrame({
'col1': [1, 2, 3],
'col2': ['A', 'B', 'C']
})
sas_data_obj = sas.dataframe2sasdata(data_df, 'WORK.mydata')
print(f"DataFrame '{data_df.shape}' transferred to SAS library WORK as 'mydata'.")
# Example: Read SAS data back into a pandas DataFrame
retrieved_df = sas.sasdata('mydata', libref='WORK').to_dataframe()
print(f"Retrieved DataFrame head:\n{retrieved_df.head()}")
sas.endsas()
Debug
Known issues
breakingWith Pandas 3.0.0, a change was made to store `None` as `NaN`, which caused `dataframe2sasdata` to throw exceptions. This was fixed in SASPy v5.104.1.fixUpgrade SASPy to version 5.104.1 or newer. If upgrading is not possible, ensure dataframes passed to `dataframe2sasdata` have `None` values converted to empty strings or other non-NaN representations.
affects: pandas 3.0.0, saspy < 5.104.1
gotchaSASPy relies on `sascfg_personal.py` for connection configurations. If you modify the original `sascfg.py` instead of creating `sascfg_personal.py`, your configurations might be overwritten during a SASPy upgrade.fixAlways copy `sascfg.py` to `sascfg_personal.py` and place your configurations in the `_personal` file. This file will not be overwritten by upgrades. The file can be located in your Python site-packages/saspy directory or in `~/.config/saspy/`.
affects: All versions
gotchaUsing `proc printto` in submitted SAS code to redirect the SAS Log or Listing can cause SASPy to hang, fail, or not return results, as SASPy parses the log for operational information.fixAvoid using `proc printto` in SAS code submitted via SASPy, or ensure `proc printto; run;` is used to revert log/listing redirection *before* any SASPy methods that require log access.
affects: All versions
gotchaSAS `ABORT` statements (e.g., `%abort`, `data _null_; abort;`) can unexpectedly terminate the connected SAS session, breaking the SASPy connection and leading to further errors.fixExercise caution with `ABORT` statements. If necessary, ensure they are handled within the SAS session logic to prevent termination if possible, or gracefully handle connection loss in Python.
affects: All versions
Upgrade
Version history
5.107.1latest on PyPI · released Apr 24, 2026
Audit
Dependencies
pandasrequiredExtensive integration for data exchange with SAS datasets.
Java Development Kit (JDK)optionalRequired for IOM (Integrated Object Model) access method to connect to SAS.
pyarrowoptionalRequired for Apache Arrow support and Arrow-based Parquet conversion (added in v5.105.0).