Skip to content
AgileLogics
6 min read

SAS Viya and CAS

Prerequisites: Working efficiently with large data

SAS Viya is SAS's cloud-native platform. It includes a SAS 9.4-style compute server — where everything in this course runs unchanged — and CAS (Cloud Analytic Services), a distributed in-memory engine that spreads data and work across many machines.

Sessions and caslibs

/* illustrative: requires SAS Viya */
cas mysess;
caslib _all_ assign;

proc casutil;
   load data=sashelp.class outcaslib='casuser' casout='class';
quit;
  • cas mysess; starts a CAS session.
  • A caslib is CAS's version of a library; CASUSER is your personal one. caslib _all_ assign; makes caslibs usable as librefs.
  • PROC CASUTIL loads a table into memory on the CAS server.

Running code in CAS

A DATA step whose input and output are both CAS tables runs in parallel inside CAS:

/* illustrative: requires SAS Viya */
data casuser.class_bmi;
   set casuser.class;
   bmi = 703 * weight / height**2;
run;

Rows are split across threads and machines, so row order isn't guaranteed, and steps that depend on it (LAG, FIRST./LAST. without BY, _N_ counters) need care.

Many procedures have CAS-enabled versions (PROC MEANS, PROC FREQTAB, PROC LOGSELECT, PROC REGSELECT), and CAS actions can be called directly:

/* illustrative: requires SAS Viya */
proc cas;
   simple.summary / table={caslib='casuser', name='class'},
                    inputs={'height', 'weight'};
quit;

PROC CAS uses the CASL language: action sets like simple, table, and regression provide the operations.

Open-source integration

  • Python — the swat package calls CAS actions from Python; saspy runs SAS code from Python and Jupyter; PROC PYTHON (in Viya) runs Python inside a SAS program.
  • R — swat for R works the same way.
  • REST APIs — every Viya service, including CAS, can be called over HTTP.

When does CAS matter?

For data that fits comfortably on one server, the compute server is simpler and often just as fast. CAS pays off with very large tables, heavy modeling (gradient boosting, neural networks, many models at once), and sharing in-memory data between users.