BookmarkSubscribeRSS Feed

SAS Viya Managing User-defined Formats

Started ‎12-05-2018 by
Modified ‎07-08-2019 by
Views 3,158

If a CAS table has columns which reference user-defined formats, the formats must be made available to the CAS server. CAS cannot directly read SAS catalogs that store user-defined formats. They must be converted to a CAS format library and stored in a sashdat file in a path based CASLIB. In addition, to be made available to all users, the CAS format library must be promoted in a global CASLIB.

 

In SAS Viya 3.4 we have some new functionality to make it easier to manage the availability of user-defined formats in both Environment Manager and the command-line interfaces.

 

Firstly, let's look at the new out-of-the-box configuration for user-defined formats. The standard install sets up:

  • One global path based CAS library named Formats located at /opt/sas/viya/config/data/cas/default/formats/
  • One CAS format library, named sassuppliedformats (sassuppliedformats.sashdat)

The CASLIB and CAS Format library are made available by being defined in the casstartup.lua file. This file runs when the CAS server starts. It is not recommended to make any changes to casstartup.lua (use casstartup_usermods.lua) or to load your own formats to sassuppliedformats. These files may be changed during a software update or  upgrade.

 

SAS Environment Manager

In SAS Viya 3.4 in SAS Environment Manager you must be a SAS Administrator to manage user defined formats. An administrator can manage formats in existing format libraries including:

  • Create new formats.
  • Copy and delete formats.
  • Import formats from an
    • itemstore file accessible from the CAS controller
    • SAS catalog accessible from the machine that runs the compute service OR a
    • table sashdat file accessible from the CAS Controller in an SMP environment and the CAS Controller and workers in an MPP environment

The ability to import formats from a sashdat table and directly from a SAS catalog is new in SAS Viya 3.4. The addition of the ability to import formats from a SAS catalog is a great new feature.

 

In addition, if a user is also a CAS administrator, and if they assume the super user role in SAS Environment Manager they can manage CAS format libraries. In SAS Viya 3.4 SAS Environment Manager a CAS administrator can:

  • Create a format library (optionally populate it from an itemstore, SAS Catalog or table sashdat file)
  • Delete a format library
  • Update the format search path.

The short video below will demo how to:

  • Create a new empty CAS format library in SAS Environment Manager
  • Import formats to the new CAS format library

 

 

 

The approach in the video is useful if you want to view the formats your are importing, and compare them to existing formats. In addition you don't need to be a CAS administrator to do the second step, importing the formats. This means that you can split the functionality so that only a CAS administrator can manage format libraries but other administrators can manage formats within the libraries.

 

An alternative approach, creates the CAS format library and imports the formats from a supported file all in one step.

 

udf_34_2.png

 

This method is more efficient when you have a lot of formats in your catalogs, but you don't get a chance to see the formats, and you do have to be a CAS administrator.

 

The ability to make these changes in SAS Environment manager is a great improvement. However, you should be aware that the only way to persist the availability of user-defined formats across server restarts is to modify the cassstartup_usermods.lua file to:

  • Load the format library into memory in the global FORMATS caslib
  • Add the format library to the CAS server format search path.

The image below shows the code to load the CAS format library into memory and add it to the search order in casstartup_usermods.lua. This file is runs every time the CAS server starts.

 

udf_34_1.png

 

Making these changes will ensure that the CAS Format library is loaded into memory, and added to the formats search order every time the CAS Server starts. The format search order is used during session startup to automatically established format libraries to search when a table a format is needed.

 

In SAS Viya 3.4 the CAS plug-in to the sas-admin command-line interface has been enhanced to allow the administrator to create format libraries, update the format search order and import formats. The command-below perform all these tasks, however, the CLI also does not persist the changes, the only way to persist the changes is to include them in CAS server startup processing.

 


./sas-admin cas format-libraries create --server cas-shared-default --format-library hrformats --search-order prepend --source-path /gelcontent/gelcorp/hr/formats/formats.sas7bcat --su

 

These changes give the SAS Viya administrator more choices for how they will make user-defined formats available to CAS in SAS Viya 3.4. 

 

For more information check out the User Defined formats section in the Viya Administration Guide h

Version history
Last update:
‎07-08-2019 05:58 PM
Updated by:
Contributors

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags