BookmarkSubscribeRSS Feed

Get Started: Using the CAS Programming Language for Distributed Computing in the SAS® Viya® Platform

Started ‎06-12-2023 by
Modified ‎06-19-2023 by
Views 963

Watch this Ask the Expert session to learn the fundamentals of the SAS Viya platform and CAS, then dive into CASL, the scripting language designed to support the entire analytics life cycle on the SAS Viya platform. 

 

Watch the Webinar

 

You will learn how to:

  • Describe the two computing engines in the SAS Viya platform.
  • Explain CASL and its components.
  • Understand when to use CASL.
  • Use CAS actions to submit requests to the CAS server and work with the results.
  • Develop analytic pipelines using CASL.

 

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

In SAS Viya, do I need to use the CAS language (CASL)?

No, you don’t. CASL is the native language of the CAS server, but you can also use SAS, Python, R, Java and more through the CAS API to process data on the distributed CAS server to accomplish everything we have done today using CASL.

 

SAS Developer Page

https://developer.sas.com/guides/open-source-sas.html

 

Python Integration to SAS Viya

https://blogs.sas.com/content/sgf/2020/06/19/getting-started-with-python-integration-to-sas-viya-ind...

 

SAS Viya Programming Documentation

https://go.documentation.sas.com/doc/en/pgmsascdc/v_039/pgmsasgswlcm/home.htm

 

 

In SAS Viya, you can use a variety of languages to work with your data. So, when should I use CASL, SAS, or Python/R?

This depends on the task you want to complete and your comfort level with the programming language.

 

For example, if you are Python programmer and want to continue to use Python, use the Python SWAT package to execute code on the CAS server, and bring back smaller, summarized results to your local Python client for additional processing using other Python packages.

 

Or if you are a SAS programmer you can use SAS Studio to execute SAS code on the distributed CAS server, and bring back smaller, summarized results back to the SAS client to continue processing using traditional SAS code.

 

Or you can use the fedSQL language to execute SQL on the distributed CAS server.

 

In the end I recommend using the language you are most comfortable with. Every language has its own benefits and considerations.

 

Can you explain the difference between the SAS compute server and the CAS server?

Viya contains 2 analytic processing engines. The SAS Compute server is just like SAS 9 (sometimes called SPRE, the workspace server, or SAS9). The Compute server enables you to run your traditional SAS code as you saw earlier – Data Step, PROC Means, ODS, Excel, all of that.

 

The CAS server is a massively parallel processing environment that can connect to the same data sources the Compute server can connect to, but if you pull that data into the CAS server, it loads the data into a distributed computing environment for massively parallel processing. The CAS server also enables you to use other Viya point and click applications for analysis, data prep or machine learning. CAS also has a variety of integration with other languages like R/Python/Java and REST APIs.

 

With the CAS server storing the data for a long as we want, does that make it require more memory/space? And secondly, does this make processing slower than in SAS computing server?

The CAS server is most likely going to be a pretty big environment. It also performs memory swapping if you're at that place where you have too much data in memory. It shouldn't make it slower because you're avoiding that input and output going from disk to memory. It will do some CAS caching or swapping.

 

Here is some information on how the CAS server manages memory: https://go.documentation.sas.com/doc/en/pgmsascdc/v_039/casfun/n16qbskv0hwfq1n1lnrqq605p6sv.htm

 

The CAS server and the Compute server are separate, so how much data that is loaded in CAS does not affect how the Compute server processes data.

 

How can you use the work you did in the CAS language in SAS Visual Analytics report building?

You can do all your data prep in the distributed CAS server using CASL (or Python/R/SAS/etc.). Once the data is ready, you can promote the CAS table to global scope so you (or another coworker) can use Visual Analytics (or other Viya applications) on that in-memory table. Promoting the table avoids saving it back to disk and reloading it into memory.

 

For more information on session vs global scope tables: https://go.documentation.sas.com/doc/en/pgmsascdc/default/casfun/n09ssmi0ko8uyfn1022ezo2hv0pm.htm#p0...

 

You can also save the CAS table into a file format like sashdat, parquet, csv, sas7bdat or back to a database. Once the data is saved back to disk, you can use Visual Analytics to load the data into memory and begin creating a dashboard.

 

For more information on saving CAS tables to disk: https://go.documentation.sas.com/doc/en/pgmsascdc/default/casref/n1fujq5fhyeiprn1whq1iva21obo.htm?fr...

 

Personally, I do all of my data preparation using code like Python/SAS/CASL. Once the data is ready, I save it back to disk in the file format I need and then load it into memory using Visual Analytics for exploration and reporting.

 

How to use SAS Macro in PROC CAS?

That's a deeper conversation. You can use the macro language with CASL. I could say %LET. Give it a string and I could use and the macro variable in CASL, but there are some “gotchas”. We don't have time to go into that now. But you can use it in Proc CAS because, again, the macro language is just going to get some text and replace the text in your code. Typically when I use CASL I don’t use the SAS macro language. I use the available variable data types in CASL.

 

I do not have clients; it is myself only. But I am running large data set, need sorting, then run time-series model. How will CAS help me?

  1. With CAS, the data resides in-memory, so you only need to load it once to process it multiple times.
  2. With CAS (like with DBMS tables), there is no need to pre-sort the data for BY group processing. The data will be retrieved using an appropriate ORDER BY clause.
  3. You can use the Time Series Analysis CAS Action set to do your analysis in parallel in CAS and return just the results to the compute server. https://go.documentation.sas.com/doc/en/pgmsascdc/default/casactforecast/casactforecast_timedata_exa...

 

How do you prevent users from filling up available server memory by loading many large datasets? Is there some sort of clean-up process that runs if a dataset is not accessed for a certain amount of time?

CAS is excellent at managing memory transparently. By default, the CAS tables you create are "session scoped" - when you disconnect the CAS session, the tables are removed from memory.

 

Is there a presentation using network analyses?

Check out https://video.sas.com/detail/video/6029136083001/intro-to-network-analysis-in-sas%C2%AE-visual-analy...

 

Can you please post python code for calling CASL? Thanks.

Check out Peter's Getting Started with Python Integration to SAS® Viya blog series: https://blogs.sas.com/content/?s=Getting+Started+with+Python+Integration+to+SAS%C2%AE+Viya%C2%AE

 

How do you load your own data?

If you are authorized, you can simply create a caslib connection to any folder location accessible to the CAS server or load local data into CAS.

 

Can you edit Python in SAS Studio? Or does it require a separate "Python Integration" product?

The October 2021 release of SAS Viya introduced the Python Code Editor within SAS Studio.

 

Does using SAS language make it less efficient?

Using the SAS language with the CAS engine to process SAS code in CAS does have some overhead because SAS procs and statements are converted into the native CAS language behind the scenes.

 

Check out some other Ask the Expert presentations:

 

Best Practices in Migrating SAS Code to Leverage CAS

https://www.sas.com/en_us/webinars/ate-best-practices-in-migrating-sas-code.html

 

Getting to Know SAS Viya

https://www.sas.com/en_us/webinars/getting-to-know-sas-viya.html

Version history
Last update:
‎06-19-2023 04:23 PM
Updated by:

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Article Tags