Debunking the myth that SAS code doesn't work in Viya: One billion lines later and the results are...


How does the Content Assessment help with code?

Migrating to a new system can be expensive and intimidating as a SAS 9 environment has many components that need to be moved. This article will focus on the code elements in an environment and debunk the myth that SAS 9 code will not run in the latest version of Viya.

The SAS 9 Content Assessment is a collection of applications that are designed to help users understand the various characteristics of their deployment. SAS Content Assessment delivers information that is critical to helping you to upgrade to the latest version of SAS (Viya).

Across the UK&I business, we have completed over 20 content assessments across the banking, insurance, commercial and public sectors. We have reviewed over 3 million individual pieces of code containing over 1 billion lines. This code has been collected from Data Integration Jobs, Enterprise Guide Projects, Base SAS and Stored Processes.

Looking at all this data and using the content assessment tool allows clearer movement paths to be created which means you can move sooner and at a lower cost point.

So, what works in Viya?

The good thing to know is that most of your SAS code will work in the same way as it does today. SAS has over 40 years of experience in the field of code, and we appreciate that you use it to run very important and critical processes. Therefore, we work hard to ensure that the latest version will run your old code.

In reviewing over 3 million pieces of code we have less than 1% which needs to be updated to the new ways of working without a metadata server. About 9% of the 3 million had hard-coded paths which would need to be changed. Hard coding is something that is prevalent across all sites and it’s something that affects all coding languages, new and old.

The next sections will discuss the changes needed to be made to your code when an exception occurs.

So, what makes up the 1%?

The 1% which have been highlighted across the 3 million pieces all fall into the following categories:



These have been around for many decades and have allowed great versatility as you can execute OS commands within a SAS program. However, as security policies get tighter and tighter the usage of XCMDs is coming under the spotlight. With that in mind, it's worth considering whether you take the opportunity of an upgrade to resolve your technical debt in this area. Many of the common OS XCMDs can be performed with SAS procedures today so if you are moving, copying, deleting, and generally managing a file system then consider the SAS alternative.


There are several procedures that simply just won't work with Viya. For example:

This procedure will not work with Viya as the concept of a metadata server does not exist. A careful review of these commands being used needs to take place and alternatives provided which allow the same functionality. In a lot of cases, the content assessment has been allowed to run against the SAS Config location which means it picks up several hits based on background SAS code.

A full list of procedures that won't work in Viya is listed below. Note that they are metadata-bound procedures or oldies which have now been replaced with more efficient procedures.


Libname (Metalib)

As we continue looking at what works, the next category is libnames. This might seem strange as a libname is generally a path and if you change the path then everything will work. The ones here are METALIBS and they won’t work in Viya because they require a metadata server to assign the libname.

Libname (Metalib)

There are a few other libname with engines that you might want to watch for.


This category of ones to watch for results for the output of a command which is not supported being assigned to a value. In this example you can see that the metadata function has been used to set the “rc”. In Viya this would fail and therefore a warning is set on the report so that an alternative can be found.

Source Code Statement

If you are using any of the following metadata functions and assigning the output, then they will be present on your report.

What about the 9% with hard coding issues?

Inevitably when people write code, they include paths that are hard coded and directly linked to the infrastructure they are processing on. It is always best, where possible, to make these paths dynamic and have macros generating the paths. This allows you to move to new hardware with limited changes. However, there is no way to mandate this best practice and hard-coded paths can end up in the top, middle and bottom of the code. We also appreciate that not all code is batch code and user-written code does not always need the same levels of control or best practices to be applied.

Some of the hard-coded items which are highlighted in the reports are:


This is an example of one which uses filename to send an email and other common ones can be paths that are then used with infile statements to read raw files.


This one shows a file being used to generate flat files and the path would need to be changed.



One of the most common hard-coded paths is libname. This example is easier to change as the macro &DATA_PATH can be changed centrally in an autoexec. In most cases the physical path is present.

Path Assignment

This one will be highlighted when a let statement is used to reference a physical path. This is another good way of referencing hard-coded paths as this path could be changed once and then applied many times across multiple pieces of code.

Path Assignment


The process will also highlight any hard-coded paths which relate to %inlcudes. These can be used to call other programs such as assigning a core set of macros for a session.



Any references with infile will also be highlighted on the report.



This all sounds like quite a lot of change to get to Viya. Does SAS offer anything to help?

The quick answer is yes. SAS has years of experience in upgrading systems and helping customers move to the latest version. The content assessment tool also has a modified SAS code element which allows the source to target the substitution of hard-coded paths. This means that the level of work to change the 9% is reduced significantly. It could also be a great opportunity to think about centralising paths, making them dynamic and ultimately creating a more portable piece of code.

Learn more


About Author

George Beevers

Migration Lead Customer Advisory, SAS UKI

George has been working with SAS for nearly two decades with the vast proportion on the customer side. He specialises in modernisation and migration of existing workloads to Viya. He has a keen interest in understanding what current SAS platforms do and how to get them operating in Viya as soon as possible.


Leave A Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Top