As SAS Viya environments grow—especially in Kubernetes and hybrid deployments—administration naturally gets more complex. Most of us already rely on tools like the SAS Viya CLI for day‑to‑day management, but there are still gaps in content movement, bulk operations, and repeatable API-driven workflows. That’s where Pyviyatools fits in as a companion tool—building on the same APIs as the sas-viya CLI.
In this post, I’ll walk through what Pyviyatools is, where it fits and how it can help a SAS Viya Administrator.
Pyviyatools is a set of Python scripts that interact directly with SAS Viya’s REST APIs. Instead of working through the Environment Manager UI—or building API calls from scratch—you get a set of ready-to-use commands for common admin tasks. Pyviyatools are available from the SAS GitHub site at https://github.com/sassoftware/pyviyatools
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
Typical tasks include exporting and importing content, managing and maintaining security, running environment-level checks, and performing environment maintenance. It’s especially useful when you need to operate at scale or repeat the same task across environments.
At a high level, it gives you a practical, scriptable layer on top of the SAS Viya APIs. You can see a list of tools classified by category here.
SAS Viya is API-first, which is powerful but also adds some friction. You have to deal with authentication, tokens, pagination, JSON payloads—all the usual pieces.
Pyviyatools handles most of that for you. You run a script, pass in your inputs, and it handles the API interaction behind the scenes. That makes it much easier to focus on the task instead of the plumbing.
Another nice aspect is the flexibility in how output is handled. Most pyviyatools support multiple output formats, such as plain text for quick reads, JSON for scripting and automation, and CSV for easy import into spreadsheets or reporting tools.
One of the nice things about pyviyatools is that almost every tool is self-documenting via a built-in help flag—just like the SAS Viya CLI
python listcontent.py -h
usage: listcontent.py [-h] -f FOLDERPATH [-v] [-o {csv,json,simple,simplejson}] [--debug]
List folder and its sub-folders and content.
options:
-h, --help show this help message and exit
-f FOLDERPATH, --folderpath FOLDERPATH
Enter the path to the viya folder to start the listing.
-v, --verbosecsv Verbose CSV(only used with -o=csv)
-o {csv,json,simple,simplejson}, --output {csv,json,simple,simplejson}
Output Style
--debug Debug
Developing a new tool is pretty straightforward, especially if you already know Python and the SAS Viya APIs. Each tool is basically a thin wrapper around an API, with some standard argument handling and output formatting. Most of the heavy lifting—like auth, connections, and common utilities—is already done for you, so you’re really just focusing on the specific API call and how you want to handle the input and output.
There is a real variety of tools available. The project includes tools for authorization, content export and import, content management, configuration management, folder operations, report handling, CAS library work, and job-related tasks. Let's focus on a couple of key areas to demonstrate what is possible.
Pyviyatools is strong in content management and migration. It simplifies using the transfer plugin of the SAS-Viya CLI and provides a straightforward way to export content—such as folders, reports, and other objects—to Viya packages, and then bulk-import them into another environment in a controlled manner. This makes it well-suited for Viya 3-to-Viya 4 modernization efforts, where you want to move content selectively rather than all at once. Because everything is scriptable, you can build repeatable workflows for migrating content between environments (dev, test, prod), validating what’s been moved, and iterating safely. Instead of treating migration as a one-time event, Pyviyatools lets you approach it as an ongoing, controlled process that can be refined and rerun as needed.
For example, the following command imports all SAS package files in a directory into a Viya environment.
python importpackages.py -d ~/tmp/content -q
Related tools support the import and export of configuration, CAS libraries and CAS authorization.
More details are available in the post here.
Pyviyatools is also valuable in authorization, enabling administrators to move from complex, manual configuration to consistent, automated enforcement of access controls in SAS Viya. Once an authorization model has been carefully defined—covering roles, groups, rules, CASLIB permissions, and folder access—pyviyatools provides the mechanism to apply those definitions programmatically at scale. By consuming structured inputs (such as the ViyaAuthModel Supplement) and translating them into API- or CLI-driven actions, it ensures that authorization policies are implemented accurately and repeatably across environments. This approach not only reduces the risk of human error but also makes it far easier to maintain, update, and reapply authorization rules over time, which is critical for governance, compliance, and managing evolving user access requirements.
One of my favorite tools testfolderaccess.py, performs a task that is otherwise not easy to accomplish in SAS Viya. It will test access to a folder for a given user or group
python testfolderaccess.py -f /gelcorp/finance -n HR -t group -s grant -m read
Exception: TEST FAILED: the effective read permission for HR on folder /gelcorp/finance is prohibit, not grant
Check out the following posts on planning and implementing a security model by Tom Starr
The inventory tools in pyviyatools make it easy to discover and catalog everything in a SAS Viya environment, giving you a complete view of content, users, security, and CAS assets. Tools like listcontent, listreports, and listgroupsandmembers enable you to query the platform and build a structured inventory for auditing, troubleshooting, or migration planning. For example, running listreports.py lets you quickly output a list of SAS Viya Reports based on search criteria.
python listreports.py -c 5 -o csv
id ,fullreport ,type ,description ,creationTimeStamp ,modifiedTimeStamp
"bc1cf716-a559-417c-aa17-751f960e12ba","/Public/SAS Content Assessment/Application Usage/SAS 9 Application Usage","report","None","2022-09-08T03:18:40.335Z","2026
"3ee8b0d9-9b27-4a11-b2ab-01dd4e410574","/Public/SAS Content Assessment/Code Check/SAS 9 Code Check for Internationalization","report","None","2021-11-15T19:35:55.
Z"
"520f577a-511a-47ad-8eb2-1767aaffd8b4","/Public/SAS Content Assessment/Code Check/SAS 9 Code Check for SAS Enterprise Guide Projects","report","None","2021-06-30T
35:36.025Z"
Pyviyatools are used widely by SAS administrators, DevOps engineers, and consultants to automate everyday Viya tasks and support migration workflows. While the core tools are developed and maintained by SAS, the project is open and collaborative—field teams, partners, and customers all contribute enhancements based on real-world use cases, making it a practical and evolving toolkit.
The project is active with new tools being added frequently. Exportjobflow.py was added to support exporting SAS Viya flows between environments. On the reporting side, newer tools like createreportpdf.py and createreportimage.py extend automation into Visual Analytics by enabling scripted generation of report outputs in PDF and image formats. Additionally, tools such as getimportresults.py and getschedulehistory.py were introduced to help administrators track import activity and job execution history, providing better operational insight and troubleshooting capability.
Find more articles from SAS Global Enablement and Learning here.
Visit the Tips & Tricks page for setup guidance, demos, and practical examples that show how Copilot supports your workflows.
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.