Migrating SAS Processes to VIYA

By Richard Paterson - Senior SAS Consultant

OCS Consulting plc

Continuing our recent theme ‘Migrating to Viya’ in this article we look at the subject from the programmer's perspective.

With the introduction of a whole new platform, SAS Cloud Analytic Services (CAS) the question of ‘What happens to my existing processes?’ will arise If you are an existing SAS customer with many users, then you likely have hundreds, if not thousands, of programs that have been generated by your user base over many years. You will want to migrate some, if not all, of your SAS programs to SAS Viya. That’s a huge task, right? Well actually as with most things SAS the answer is … it depends.

Stay CALM and use the SPRE

With SAS Viya we are introduced to the new multi distributed in memory compute engine - the CAS engine. The good news is we keep the ‘old’ 9.4 compute engine in the form of the SAS programming run-time environment (SPRE). We now have two engines that support a common SAS Platform.  In a SAS Viya environment, some of the Base SAS procedures can take advantage of a CAS server, and others simply run on a traditional SAS Foundation server. It is important to realise not all procedures and DATA Step statements are CAS enabled. This is because not all procedures and statements are eligible for distributed processing. This however is not a problem since these non-CAS enabled procedures and statements will simply run in SPRE (the compute server in SAS Viya).

The SAS Programming Runtime Environment (SPRE) is also referred to as the compute server in SAS Viya. You can think of this engine as a SAS Workspace Server. The primary difference between SPRE and a workspace server is SPRE does not support the SAS® Metadata Server technology.

 SAS 9.4 programs can run unmodified...in Viya?

So, returning to our question … what happens to my existing processes? We can see that existing SAS 9.4 programs can run unmodified within a SAS Viya client session. Because SAS Viya deployments include a full SAS programming run-time environment, they can provide similar support to developers without the need for a separate SAS 9.4 environment. A SAS Viya client can execute both SAS 9.4 code in the SAS programming run-time environment and SAS Viya procedures using a CAS server.

I did however state that the answer ‘depends’.  If all we want to do is run existing processes, then why are we migrating to Viya? Obviously, we want to start taking advantage of all the distributed in memory processing power now available to us. Of course, there are some issues we need to be aware of.

 Migration Steps

 There are four main steps to follow when migrating processes to Viya. These steps are summarised below -

Step 1:

Run your program without modification in the SPRE. Here we are testing the code and checking that the code will run in the SPRE. In this step we need to be aware of some gotchas -

Be aware of any code trying to access the metadata server. Remember there Is no metadata server.

Watch out for metadata libraries. These are not allowed.

The same goes for libraries using authentication domains.

And one final gotcha – The SASIOLA engine is not supported in SPRE and therefore updating your LASR tables from the SPRE is not going to work (and why would you when you have CAS?)

Step 2:

Where appropriate replace your existing Libnames with CASLIB’s. Remember where possible SAS will use CAS enabled functionality. However, these procedures require source and target data to be stored in a CASLIB. These CASLIBs provide access to data from the data source and access to in-memory tables that are copied from the data source. If this is not the case, then SAS will redirect the processing to the SPRE.

Step 3:

Now the work begins, we can now evaluate the process and determine how we can best utilise CAS to speed things up. Do not try to convert enerything into CAS – be selective and identify exisiting procedures that can be replaced by CAS enabled procedures AND will have a significant performance increase. For example -

Long-running steps, which are steps that run for 30 minutes to multiple hours.

CPU intensive steps.

DATA Steps containing a lot of computations, functions, and conditional logic.

Data volumes greater than 50GB. This is a general baseline recommended by SAS.

You can find a list of CAS-enabled procedures in the SAS 9.4 and SAS Viya 3.4 Programming Documentation: Base SAS Procedures Guide. Some of the more obvious procedures are -

PROC MEANS, PROC TABULATE, PROC REPORT, PROC SUMMARY, PROC TRANSPOSE, PROC APPEND, PROC CONTENTS, PROC DATASETS, PROC FORMAT

To utilise the CAS enable version of these procedures ensure that all source and target tables for the procedure are stored in a CASLIB.

Note: PROC SQL is currently not CAS enabled...however FedSQL is CAS enabled and is SAS FedSQL is an implementation of the ANSI SQL:1999 core standard.

The datastep in now also CAS enabled, again we need to ensure that the source and target tables are stored in a CASLIB. In general, our code will remain the same except the DATA step will now run-on multiple machines with processing workload being divided among these machines.

 Migration Services

This has been a quick introduction to migrating SAS code to the Viya platform and we will dive into more depth in the coming newsletters. As more customers adopt the new Viya platform we at OCS are developing a set of best practices to help this process go smoothly. If we can help you in any way with your current or future migration plans, then please contact us. We would be delighted to help with the creation of a migration plan, document the migrations steps needed or work together to provide knowledge and execute a successful migration to Viya.