Watch this Ask the Expert session to learn how to use the CAS programming language for writing automated, self-modifying, data-driven programs.
You will learn how to:
The questions from the Q&A segment held at the end of the webinar are listed below, and a link to the ZIP file containing a PDF of the slides as well as the code and data used to create the webinar can be found in the Recommended Resources section below.
Q&A
Do you need to make a MYCAS library or is it default like sashelp?
In my presentation, I made the myCAS caslib because I wanted a CAS library, or caslib, associated with a folder where I stored the data files for my presentation, and I wanted to be able to easily show you the contents of that folder. But everyone who logs into Viya and starts a CAS session gets an automatically generated caslib called CASUSER. You can certainly store files in there, and work with data in CASUSER instead of myCAS. There really was nothing magical about the myCAS library - I just wanted to be able to easily show you where my data files were sourced.
Does SAS offer free SAS Viya access for students who would like to practice?
As of right now, there's a SAS Viya for Learners, but it's restricted to users with EDU-domain email addresses. To gain access, you’ll need to sign in using your university email account.
Can CAS be used in SAS AWS platform?
As long as you have SAS Viya, it doesn't matter what platform you're on - SAS Viya will always make CAS available to you.
Have you performed some performance comparisons between CAS and the macro engine on SAS Compute?
The truth is when we talk about performance, the macro code itself has almost a negligible effect on the performance. With performance overall, what's going to matter most is the code that was generated. The two big things that cause delays or latency in your runtime are disk IO and execution time for functions and the number of instructions you have to execute. Generally, macros have a few – maybe 10 to 1000 instructions – and they're only compiled and executed once. It’s the code they generate that causes the hit on your performance. And the same goes for CASL code that's generating code to be run. The code generated will cause any performance hits. I don't think that there's any real performance difference between using CASL or macro to generate code.
What will be the best practice to improve macro coding? Any sample macro code available for practice purpose? Where can we find example CAS codes to train ourselves at early stages of using SAS Viya?
I have a public GitHub stash of macros that I personally use all the time, and so I share them with people. You can find them here: https://github.com/SASJedi/sas-macros
There are a lot of other folks out there who have vast repositories of SAS macro code, if you want to look at other macro code to see how people are doing things. One very extensive example is the SASjs core macro stash: https://github.com/sasjs/core As far as CASL code goes, as of right now I'm not aware of any CASL repositories out there. But I’ve just finished collaborating with the SAS Documentation folks to add working examples for most CASL statements, common functions, and built-in functions. Check out the SAS® Cloud Analytic Services: CASL Reference in the Online Docs.
Can you run Python code in SAS Viya?
Yes, there is a PROC PYTHON and numerous other ways of integrating Python with SAS Viya. I'm not heavy on Python - I've just played with it a little bit. I know that there are ways of running Viya from Python and running Python from Viya, so those can all interact whichever way you prefer. Check out Integrate SAS with Python for more info.
How can I write the contents of a CAS result table variable to a SAS data set?
Generally, the CAS result table produced by running a CAS action is already in your compute server, even if you’ve connected to CAS from a SAS 9 session. All you need to do is run the CASL SAVERESULT statement, and you tell it what to save and what to name the table. There's an example of that in the code for this presentation, which you can download in the ZIP file.
Can CAS run on SAS 9.4 in windows desktop?
OK, while the SAS Viya Compute Server does everything SAS 9 does, CAS is only available in SAS Viya, not SAS 9. If you are running SAS 9, you must have access to SAS Viya to access CAS. You can connect to CAS from SAS 9 if you have access to a SAS Viya instance somewhere. You may have to set some environment variables to get authentication working properly.
Can you use CASL variables to generate DATA step code?
Well, kind of. You can't get it to execute on the compute server, though. Proc CAS doesn't run data step code, but you could generate data step code and execute it on the CAS server. There's a special action called runCode that you could use to run data steps on a CAS server. But you can't use CASL to generate a data step and then execute in Base SAS or the Viya SAS compute server.
Can a macro variable be used to supply the value of a CASL variable?
Kind of. Remember when we saw how you were writing your code? Before that code got passed to CAS server, the text was parsed by the word scanner and all macro code was resolved. So, if you had a CASL assignment statement that said X= &macVar, then the macro variable value would resolve before the code was passed to CAS for processing, and the CASL variable X will be assigned the value stored in macro variable macvar when the CASL code executes.
Can I use CAS/CASLIB in my SAS 9.4 EG SAS Enterprise Guide? If yes, then where I will get details?
Yes, but you will need an up-to-date version of Enterprise Guide and access to SAS Viya 3.5 or SAS Viya 4 in addition to access to your existing SAS 9. Here are links to good information about it:
Recommended Resources
Please see additional resources in the Notes PDF.
Ready to level-up your skills? Choose your own adventure.
Your Home for Learning SAS
SAS Academic Software
SAS Learning Report Newsletter
SAS Tech Report Newsletter