We've covered CASL Result variables and the CASL _Perf variable. So let's move on to the CASL _Status variable. Like the _Perf variable, the _Status variable is set/updated after each CAS Action execution, and, like the _Perf variable, the _Status variable is a CASL dictionary. It includes the following attributes:
- severity
- reason
- status
- statusCode
The severity tells us whether or not the CAS action was successful, 0 for success, 1 for warning, and 2 for error. While the other attributes add detail about the status. See here for the documentation. .
Looking at a simple example, we see we can print _Status just like we printed _Perf in this previous post. You can also give the _Status variable a different name using the Status= CAS action option ('status=s' in the example). This can be useful if you want to create a complex condition on the status of more than one CAS action.
A Simple Example of _Status
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
Using CASL conditional programming, CAS Action Status information can help give CASL scripts fault-handling capabilities. For example, below we see a simple script that checks the table load status before running some analytics.
Simple Conditional CASL _Status Code
For more on CASL programming, see the following links.
- CASL: It’s like Base SAS with the MACRO Built-In
- CASL: CAS Action Result Variables
- CAS Action Computed Columns
- _Perf: CAS Action Performance Metrics
- "CAS Stored Process" with my Favorite Action Hero runCasl
- CASL Reference
Find more articles from SAS Global Enablement and Learning here.
Is there a way to return a bad syscc / sysrc code from the PROC CAS?
Hi hrczeglo, you'll have to do something like below. We use the status=s option to put the _status info into the s CASL variable and then we use symputx function to put the _status statusCode in the syscc macro variable.
proc cas;
simple.summary result=r status=s /
inputs={"actual","predict"}
subset={"sumb"}
table={name="prdsale" caslib="dm" groupby={"prodtype"}}
casout={name="prdsaleSum" caslib="dm" replace="true" replication=0};
print _status;
call symputx('syscc', s.statusCode, 'G');
quit;
%put ***syscc is &syscc.***;
The above example fails because the "sumb" variable does not exist and the "print _status" and "%put ***sycc is &syscc.***; statement outputs look like this:
{severity=2,reason=6,status=Error parsing action parameters.,statusCode=2720411}
NOTE: PROCEDURE CAS used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds
90
91 %put ***syscc is &syscc.***;
***syscc is 2720411***
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.