In SAS Viya, you have multiple ways to define your SAS libraries. In this post, we will walk through the different ways of creating SAS libraries in SAS Viya and describe what their benefits are.
@GerryNelson wrote a nice post some time ago about managing SAS libraries using the “New Library Connection” dialog in SAS Studio. Please check it out to get more details about some approaches explained later, especially in part 2. @DavidStern wrote a very useful post too that will help understand the scope of the various ways to define libraries.
Finding a way to set up a library is still highly correlated to finding where to set up an autoexec in SAS Viya. We’ll see that this is slowly changing as new approaches become available.
In SAS Viya, we have multiple ways to start a SAS session depending on how we instantiate it. SAS Studio users will start a compute server. Automated tasks, run through the SAS Viya CLI for example, will probably start a batch server. SAS 9 users might start a connect server in SAS Viya.
So, a server is the highest level for defining an autoexec and thus SAS libraries.
You can specify an autoexec and SAS libraries in SAS Environment Manager for the specific server. Below is an example of an autoexec set up for the compute server:
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
Defining a library at this level means it will be available globally to all users starting a compute server. So, it is a good way to make your shared libraries available to all SAS users, regardless of the context they will be using.
The same configuration exists for batch and connect servers. If you want this library to be available everywhere, then you would also have to add it to the batch and connect autoexec. The configuration steps are similar.
Under the server, there is this concept of context. A compute server is run under a compute context. A batch server is run under a batch context. Etc. A context provides additional specific configuration to run a particular server. By definition, “a compute context is a specification that contains the information that is needed to run a compute server”.
Contexts exist for compute, batch and connect servers. However, only compute contexts allow an admin to specify an autoexec.
There are some pre-existing contexts out-of-the-box:
SAS Studio compute context is the default context used when you open SAS Studio.
You can create your own contexts (group-based, project-based), for example to provide dedicated resources to groups of users, or to a specific project. And then provide them with different libraries, or same library names pointing to different locations.
You still use SAS Environment Manager to define an autoexec on a context like in this example below:
In addition, a SAS Studio user can add his own library definitions in his own private autoexec. This autoexec is not tied to a computing environment but rather to a user. This means that, regardless of the context the user chooses, the libraries defined in his autoexec will always be available to him (in SAS Studio). We’ll see in the recap, part 2, how the different scopes work together.
Here is how to add libraries to one’s SAS Studio autoexec:
At this point, in SAS Studio, I have 3 different libraries coming from 3 different levels of configuration:
Stay tuned for the second part of this article where we will explore additional ways of creating libraries and how they impact what we have seen so far.
Thanks for reading.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.