SAS Viya has opened an entirely new set of capabilities, allowing SAS to analyze on cloud technology in real-time. One of the best new features of SAS Viya is its ability to pair with open source platforms, allowing developers the freedom of language and implementation to integrate with the power of SAS analytics.
At SAS Global Forum 2018, Sean Ankenbruck and Grace Heyne Lybrand from Zencos Consulting led the talk, SAS Viya: The Beauty of REST in Action. While the paper – and this blog post – outlines the use of Python and SAS Viya, note that SAS Viya integrates with R, Java and Lua as well.
Nonetheless, this Python integration example shows how easy it is to integrate SAS Viya and open source technologies. Here is the basic workflow:
- A developer creates a web application, in a language of their choice.
- A user enters data in the web application.
- The collected data that is passed to Viya via the defined APIs.
- Analysis is performed in Viya using SAS actions.
- Results are passed back to the web application.
- The web application presents the results to the user.
About the process
SAS’ Cloud Analytic Services (CAS) acts as a server to analyze data, and REST API’s are being used to integrate many programming languages into SAS Viya. REST stands for Representational State Transfer, and is a set of constraints that allows scalability and integration of multiple web-based systems. In layman’s terms, it’s a set of software design patterns that provides handy connector points from one web app to another. The REST API is what developers use to interact with and submit requests through the processing system.
CAS actions are what allow “tasks” to be completed on SAS Viya. These “tasks” are under the categories of Statistics, Analytics, System, and Data Mining and Machine Learning.
Integration with Python
To access CAS through Python, the SAS Scripting Wrapper for Analytics Transfer (SWAT) package is used, letting Python conventions dictate CAS actions. To create this interface, data must be captured through a web application in a format that Python can transmit to SAS Viya.
In order to connect Python and CAS, the following is necessary:
• Hostname
• CAS Port
• Username
• Password
Let’s see it in action
As an example, one project about wine preferences used CAS-collected data through a questionnaire stored in Python’s Pandas library. When the information was gathered, the decision tree was uploaded to SAS Viya. A model was created with common terms reviewers use to describe wines, feeding into a decision tree. The CAS server scored the users’ responses in real-time, and then sent the results back to the user providing them with suggested wines to match their inputs.
Code to utilize tree:
conn.loadactionset("decisionTree") conn.decisionTree.dTreeTrain( casOut = {"name":"tree_model"}, inputs = [{vars}], modelId = "DT_wine_variety", table = {"caslib":"public", "name": "wines_model_data"}, target = "variety") |
Conclusion
SAS Viya has opened SAS to a plethora of opportunities, allowing many different programming languages to be interpreted and quickly integrated, giving analysts and data scientists more flexibility.
Additional resources
- At Your Service: Using SAS® Viya™ and Python to Create Worker Programs for Real-Time Analytics, Jon Klopfer, Scott Koval, and Mia List
- SAS Viya
- sas-viya-programming on github
- python-swat on github
- SAS Global Forum
Additional SAS Viya talks from SAS Global Forum
- A Need for Speed: Loading Data via the Cloud, Henry Christoffels
- Come On, Baby, Light my SAS® Viya®: Programming for CAS, David Shannon
- Just Enough SAS® Cloud Analytic Services: CAS Actions for SAS® Visual Analytics Report Developers, Michael Drutar
- Running SAS Viya on Oracle Cloud without Sacrificing Performance, Dan Grant
- Command-Line Administration in SAS® Viya®, Danny Hamrick
- Five Approaches for High-Performance Data Loading to the SAS® Cloud Analytic Services Server, Rob Collum