Are you just getting started with SAS Viya 4 and looking to build models?
As someone new to the world of SAS, running python code outside of Model Studio helped me gain a better understanding of the underlying SAS architecture.
In this article we are running the notebook within Azure Machine Learning Workspace and are connected to a typical SAS Viya 4 instance. Check out this GitHub page for the Notebook used in this example.
Connect to SAS Viya 4 with Azure Machine Learning Workspace Notebooks. You can also leverage this same code in your own local environment with Jupyter.
The first step is to import the official SAS Viya 4 Python Library: SWAT
Next, we will need to generate an authentication code to be used in downstream processes.
https://myviya4instance.com/SASLogon/oauth/authorize?client_id=SWAT&response_type=code
Example of an Authentication Code - easily copy/paste into your Notebook
After you authenticate, we are ready to create a connection to SAS Viya 4
A boilerplate connection string for SWAT
Next, we will load an Action Set
Now that we have established a connection and loaded our Action Set, let's interact with a dataset
From here, you are off to the races! A minimalist example is below.
Basic Example of SWAT
Congrats - you have successfully run a python version of a SAS Viya 4 model!
Check out the official SWAT API Reference for additional details and examples.
Do you have feedback or are looking for more examples? Get in touch with us by commenting below!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.