New functionality in SAS Viya now allows administrators to define and manage Base SAS Libraries for the SAS Programming Run-Time engine. This is accomplished using SAS Studio to define Connection to a Library Data Source and SAS Environment Manager to manage the availability of the data source in Compute Contexts. In 2022.1.3 this new feature will support the migration of SAS 9 Base libraries to libraries in the Viya Programming runtime. In this first post, I will look at how you manage Connections to Data Sources in Viya. In a follow-up post, I will look at the migration of Base libraries from SAS 9 to libraries on the Compute server in SAS Viya.
In SAS Studio the “New Library Connection” dialog allows you to define a Library connection to a Base SAS library Data Source. What this does is make a SAS library available for a SAS session. The library is allocated based on the "metadata" in the Data Source Definition.
There are two ways to persist a library definition beyond the current SAS session.
They are shown in the screenshot below:
Let's look at what these options do.
Firstly, individual users can Assign and connect to data sources at startup.
Selecting this option adds the LIBNAME statement to the SAS Studio autoexec file for all Contexts but only for this user. As you can see in the image below, the LIBNAME statement in the autoexec references the data source with the LIBDEF= options using the data sources URI. The LIBDEF= option on the LIBNAME retrieves pre-defined LIBNAME information from the Data Sources microservice and performs a LIBNAME assignment using that information.
SAS Help Center: LIBRARYDEFINITION= LIBNAME Statement Option
A Viya administrator(member of the SAS Administrators group) has additional options available that allow them to define a Connection to a Data Source that is available to all users of one or many compute contexts. This functionality is governed by selecting Allow all users to view the library connection.
If you choose:
Disconnected libraries are useful for libraries that are used infrequently, they can save on server startup times.
There are some important details you should be aware of before you create Connections to a Base SAS library data source. To define a connection, you must have the following:
To Configure SAS Studio in Environment Manager under Configuration > All Services select SAS Studio and edit sas.studio. SAS Studio Configuration Options are documented here.
In SAS Studio the Allow all users to view the library connection option applies to each Context separately. Creating a Connection to a Data Source in SAS Studio also makes the resource available to all the Contexts in SAS Environment Manager. Let's look at how we can manage the connections in EV
For any of the Connections to Data Sources created in SAS Studio, an administrator can edit the properties of a context to:
To access this functionality select Contexts in EV, edit the context, and in the dialog select Resources.
The data source definitions do not reside in folders and are created with READ permissions for all authenticated users. Operating system permissions to the library physical paths are respected by the Compute server when the libref is assigned. This means that if a user cannot read the file-system directory they will not see the library in their SAS session.
Permissions on the definitions could be changed using the authorization plug-in of the sas-viya CLI. To do this you will need the URI of the data source. TIP: interactively the easiest way to find the URI is to select Assign and connect to data sources at startup and then view the URI in the autoexec. In batch, you can use your favorite REST client. Here I use callrestapi from the pyviyatools:
callrestapi.py -m get -e "/dataSources/providers/Compute/sourceDefinitions?filter=eq(name,'Financial Data')"
Prior to the release of this new functionality an administrator had to add a libname statement to the autoexec of the Compute Server in SAS Environment Manager to have SAS libraries be made available to users on the startup of a SAS session. I covered how to do that in this post.
This functionality is still available. These libnames can be added using a traditional LIBNAME statement or a LIBNAME statement that references the data source definition. Libraries allocated in this way are assigned and connected for all SAS Compute sessions and may not be modified using the interface in SAS Studio.
Recent updates for SAS Environment Manager and SAS Studio make it easier for Viya administrators to manage the availability of Base SAS Libraries to Viya Compute Servers. In this post, I have described these changes and how you might use them. The two main takeaways are administrators can:
It is important to note that this is the first step in making it easier to manage libraries in Compute. The data source definition provides metadata around connections to libraries within Viya. More work is planned in this area to provide some of the robust functionality we had in SAS 9.4 around management and authorization etc.
The availability of data source definitions that define the Base libraries has enabled, in 2022.1.3 the migration of Base SAS Libraries to Viya Compute libraries in support of migrated content that uses the Compute server (Studio Flows, Jobs, etc.). I will cover how the migration of SAS 9 libraries to Viya works in a follow-up post.
Many thanks to my colleagues Scott McCauley, Amy Peters, and Dave Mackie for their assistance with this post.
Find more articles from SAS Global Enablement and Learning here.
Dear @GerryNelson
As stated:
Disconnected libraries are useful for libraries that are used infrequently, they can save on server startup times.
In SAS9 it was possible to use meta engine to assign predefined libraries as they were describer in metadata.
for example:
libname MYDATA meta library=“MYDATA“;
As libraries are now described in Data Sources microservice and meta engine is no longer available - how can we now use "MYDATA" (i.e library name) to assign predefined library with statement in SAS code and avoid using the long URI with LIBRARYDEFINITION option.
Thank you in advance!
Hi @GuidoG, at the moment, you are stuck with the need to reference the long URI. I will provide feedback to the development team that this is not user-friendly.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.