Skip to content

lleytonse/Integrate-SAS-with-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Working with SAS from Python: SASPy, SASCTL, and SWAT

Overview

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.

What Does This Notebook Cover?

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

Prerequisites

  • An active SAS Viya environment
  • Python environment with the required packages installed:
    • saspy
    • sasctl
    • swat
    • Common data science libraries such as pandas, matplotlib, and scikit-learn as needed

Installation

Create or activate your Python environment and install the required packages:

pip install saspy sasctl swat

Depending on your notebook content, you may also want:

pip install pandas matplotlib scikit-learn torch

After installation, configure your environment to authenticate with your SAS Viya services and SPRE/CAS resources.

Package Overview

SASPy

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

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

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.

Quick Resource Links

Contact

Change Log

  • Version 1.0.0 (06APR2026)
    • Initial release on GitHub

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors