Getting Started on SAS Viya 4 with Python
- Article History
- RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
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
- SWAT (Scripting Wrapper for Analytics Transfer) provides an interface to the SAS Cloud Analytic Service (CAS)
- Don't forget to run a pip install swat command on your first attempt
Next, we will need to generate an authentication code to be used in downstream processes.
- Simply generate a code and copy/paste into your Notebook.
- Long-time SAS users may notice this example demonstrates a relatively new approach to Authentication for SAS Viya 4.
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!