BookmarkSubscribeRSS Feed

_Status: The CAS Action “Return Code”

Started ‎05-27-2021 by
Modified ‎05-27-2021 by
Views 5,355

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. .

 

Simple _Status Example

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.

 

ssf_1_tatus-1.png

 

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.

 

 

Conditional Execution based on _Status

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.

 

sf_2_status1-2.png

 

Simple Conditional CASL _Status Code

 

Want More CASL?

For more on CASL programming, see the following links. 

 

Find more articles from SAS Global Enablement and Learning here.

Comments

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***
Version history
Last update:
‎05-27-2021 11:30 AM
Updated by:
Contributors

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!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Labels
Article Tags