A practical starter notebook that explores how Python users can connect to and work with SAS technologies using three key packages: SASPy, SASCTL, and SWAT.
This notebook demonstrates how a Python environment can interact with SAS compute services, CAS, and model management capabilities in SAS Viya. It walks through a range of workflows, from starting sessions and exploring data to running SAS code, building analytical models, and extending into deep learning examples.
This notebook includes examples and walkthroughs for:
- Importing packages and starting SASPy, SASCTL, and SWAT sessions
- Exploring and visualizing data
- Running SAS code from Python
- Analytical modeling using SAS/CAS procedures and Python models
- SAS Deep Learning Model Training & Registration
- PyTorch Deep Learning Model Training & Registration
- An active SAS Viya environment
- Python environment with the required packages installed:
saspysasctlswat- Common data science libraries such as
pandas,matplotlib, andscikit-learnas needed
Create or activate your Python environment and install the required packages:
pip install saspy sasctl swatDepending on your notebook content, you may also want:
pip install pandas matplotlib scikit-learn torchAfter installation, configure your environment to authenticate with your SAS Viya services and SPRE/CAS resources.
SASPy enables a Python developer, especially one familiar with Pandas DataFrames or SAS data sets, to leverage the power of SAS by connecting a Python process to a SAS session and submitting SAS code from Python. In this notebook, a SAS Programming Runtime Environment (SPRE) compute server running as part of a SAS Viya installation is used to demonstrate how Python can execute SAS programs and exchange data with SAS.
SASCTL is a Python package that simplifies interaction with SAS Model Manager and other SAS Viya services. It is especially useful for model lifecycle tasks such as:
- registering models
- validating models
- deploying models
- monitoring model performance
This notebook introduces SASCTL in the context of model management workflows that complement Python-based and SAS-based analytical modeling.
SWAT (SAS Scripting Wrapper for Analytics Transfer) is a Python package that provides an interface to CAS, the core analytic engine of SAS Viya.
Using SWAT, users can:
- connect to CAS from Python
- load and transfer data
- execute CAS actions
- perform distributed analytics in-memory
This notebook uses SWAT to demonstrate how Python can interact directly with CAS for scalable data processing and analytics.
- Pankaj Attri (pankaj.attri@sas.com)
- Lleyton Seymour (lleyton.seymour@sas.com)
- Version 1.0.0 (06APR2026)
- Initial release on GitHub