BookmarkSubscribeRSS Feed

How Do I Use Python in SAS® Viya®? Q&A, Slides, and On-Demand Recording

Started ‎12-17-2021 by
Modified ‎01-28-2022 by
Views 4,822

Use Python in SAS Viya.jpg

 

Watch this Ask the Expert session to learn how to process, analyze and visualize data using Python in SAS Viya. We’ll introduce the fundamentals of SAS Viya and Cloud Analytics Services, or the CAS Server and why you would want to use the CAS Server and Python together. 

 

Watch the webinar

 

You will learn:

  • Why you should use SAS Viya and Python.
  • How to access data in Viya using Python and the SWAT package.
  • How to process and analyze data using the Pandas API in the SWAT package.
  • How to visualize data in Viya using Python.

 

The questions from the Q&A segment held at the end of the webinar are listed below and the slides from the webinar are attached.

 

Q&A

The SWAT package needs to be on the client only and not in the CAS server?

Yes, that is correct. Python was on my client.

 

Does Pandas, Numpy or any other Python package execute in CAS?

No, you need the SWAT package to connect to CAS, execute stuff there and the key is the SWAT package again combines the world of Pandas and CAS with CAS actions. You do your processing in CAS and it returns something back depending on what you've done. Once you get that summarization of that big data, that's when you have at it with your traditional Python packages like you saw me use the plotting package in Pandas. I use a Seaborn style. So, processing summarization happens on CAS. Small stuff gets sent back to you or smaller and then have at it with your local Python packages.

 

Why would I use CAS and Python?

So, when I was talking about it earlier, it depends on your data size, right? I had a variety of reasons. I'll just go through them quick. CAS is a massively parallel processing environment, so if you have huge data, you'll want to use that. If you want to just maybe prepare data either locally or in CAS and use another application like Visual Analytics, you could do that. The CAS server will be connected to a variety of data sources. I've seen up to 100-110 different data sources that are all connected through CAS that you can now easily access. And again, sometimes you just want to pull that CAS table locally. It is not big enough to use CAS and you don't always need it. But, maybe it is connected to some cloud data that you have no idea how to get to, other than through CAS. Pull it locally, do what you need, and if you want, you can recreate a table.

 

How do I know where the processing of data occurs?

Great question, so that took me a bit, but if you have a CAS table and you do something to a CAS table object, that happens in CAS, period. A CAS table group by and a CAS column. If you have those objects, they process in CAS. If you ever see your object as a data frame, Pandas or a SAS data frame, that is a data frame on your client. Same with the series. Objects that CAS knows to process include a CAS table, CAS column, CAS table groupby… There might be one other one I'm missing. But, everything else that's data frame series are all local. If you see a CASResults object, that is a dictionary on your local client.

 

When would you compress a CAS table?

That’s a tough one because it just depends on how big is the data? How big is your environment? Do you need to save resources? Do you need a save? Do you need to save memory space? Do you need to save physical space? So, that's a tough question to ask without tons of specifics. But, that just it depends.

Check out the SAS Documentation for more information: Data Compression

 

What other editors have you tested with SWAT, can we use Pycharm?

It should, yeah, any editor should work for data processing. I just love Jupyter lab. I love the using the cells and markup language. I love seeing what I did real quick. But yeah, you should be able to use any editor, like Spyder or PyCharm. It's just a package that connects to the CAS server.

 

Are there Numpy functions implemented in CAS?

That one I'm not 100% sure. I feel like in the doc I've seen something where you can pull things back as certain objects, but again, I don't think there there's any specific Numpy ones I'm aware of, and again, you can't run Numpy in CAS, so you'd have to check the doc, which I'll link out to. And it's in my notebooks at the top that you can kind of go through the API reference and see what's available.

 

Check out the SWAT Documentation for numpy features: SWAT API Reference

There are a few methods to represent CASTable as a Numpy array.

 

May I ask you to discuss at a very high level, other ways to run Python in Viya - PROC FCMP, open source code editor in Model Studio, REST API, etc.?

Here are a few resources to get you started:

 

How do I access CAS out of my organization, for personal projects?

 

How are organizations charged for CAS memory/capacity?

This would depend on where SAS Viya is running.

 

My question might be out of scope, but there is open source node in build model section on SAS Viya. What kind of python codes can we write there (i.e can I import tensorflow there)?

These links might help:

NOTE: There is an open source modeling node, and based on variability in installation and configuration, you might need to speak with your deployment and administration folks on particulars on the way Python is accessed from Model Studio. It also does not execute the Python code in CAS.

 

Recommended Resources

Getting Started with Python Integration to SAS® Viya® - Index

CAS Action! - a series on fundamentals

SAS Tutorial | Python Integration with SAS Viya

Python hands-on-workshop - GitHub

Python-integration-Viya demo - GitHub

SAS opens its code editor interface to Python users

55% Off SAS Certification Exams

 

Want more tips? Be sure to subscribe to the Ask the Expert board to receive follow up Q&A, slides and recordings from other SAS Ask the Expert webinars.  

 

SAS®… THE POWER TO KNOW®

 

Panagiotis_0-1639774054358.jpeg

 

 

Version history
Last update:
‎01-28-2022 01:44 PM
Updated by:
Contributors

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Article Labels
Article Tags