BookmarkSubscribeRSS Feed

SAS® Viya™ Caslib

Started ‎09-18-2020 by
Modified ‎09-23-2020 by
Views 16,073

In SAS® Viya™ a caslib is an in-memory space on the CAS server to hold tables, access controls, and data source information. A caslib provides access to data from the data source environment and access to in-memory tables that are loaded to CAS from data sources. Caslibs create an association with access controls that define which user groups and individual users are authorized to access the data tables listed within a caslib.

 

Caslib type

A caslib can be personal, pre-defined, or manually added to the CAS server. The user authorization determines the user interaction with each type of caslib.  

 

Personal caslib

A personal caslib can be configured while installing and configuring the CAS server. When a CAS session is initiated, the personal caslib is always available with global scope. This enables users to access CAS tables from any session with the same user ID. For example, in your test SAS Viya environment, you can have ‘casuser’ as the personal caslib.

 

Pre-defined caslib

Pre-defined caslibs are defined and managed by CAS administrators and have global scope. The data access controls are managed by the CAS server administrator to grant the permission to multiple users for caslib access. Pre-defined caslibs are used for popular data sources utilized by a range of CAS users. For example, in your CAS environment, you might have pre-defined caslibs for Hadoop-Hive or Oracle data sources.  

 

Manually added caslib

Authorized users can add caslibs to the CAS server by running a caslib statement from SAS® Studio. In general, the manual caslibs are added in a program where there is need for ad hoc data access and users do not want to share the same data with all other users on the CAS server.   

 

 

Caslib scope

The caslib is an in-memory space in the CAS server to hold tables. When a data table is loaded to the CAS server under caslib, the caslib scope, in association with access controls, facilitates CAS table access for users. Depending on the caslib scope, the CAS table can be shared with other users. There are two scopes for caslibs: session and global.  

 

Session-Scope caslib

When a caslib is defined without including the GLOBAL option, the caslib is a session-scoped caslib. When a table is loaded to the CAS server with session-scoped caslib, the table is available to that specific CAS user session only.  

 

The following SAS code illustrates the creation of a manual caslib (HiveCaslib) defined as a session scope and data loaded to the CAS server within the same caslib. Notice, the CASLIB statement has no GLOBAL option. The PROC CASUTIL statement to load data to the CAS server also does not have the PROMOTE option. The PROMOTE option is valid only when the caslib is defined with global scope.

 

CAS mySession host="gatekrbhdp01.gatehadoop.com" SESSOPTS=( CASLIB=casuser TIMEOUT=999 LOCALE="en_US");

 

/* Assign Std HIVE CASLIB */

caslib hivelib desc="HIVE Caslib"

    datasource=(SRCTYPE="HIVE",SERVER="gatekrbhdp01.gatehadoop.com",    

    HADOOPCONFIGDIR="/opt/sas/hadoop/client_conf/",

    HADOOPJARPATH="/opt/sas/hadoop/client_jar/",

    schema="default",dfDebug=sqlinfo);

 

/* Load HIVE tables (In memory) */

proc casutil;

   load casdata="stocks" casout="stocks" outcaslib="hivelib" incaslib="hivelib";

quit;  

 

 

After loading data, when PROC CASUTIL is executed using the list table statement from the same user session, the output is displayed as a session-local caslib along with associated tables.

 

proc casutil;

   list tables incaslib="hivelib";

run;

 

caslib_1.PNG  

When the same user initiates a new session and tries to access a caslib and table loaded from the previous session, the caslib and table are not available in the new session since it was session-scoped. The following SAS code illustrates the creation of a new session by the same user who is trying to access the caslib and associated table that were loaded in the previous session. Notice the “CAS mySession2…..” statement.

 

CAS mySession2 host="gatekrbhdp01.gatehadoop.com" SESSOPTS=( CASLIB=casuser TIMEOUT=999 LOCALE="en_US");

 

proc casutil;

   list tables incaslib="hivelib";

run;  

 

 

SAS log with error message:

56

57 proc casutil;

NOTE: The UUID 'fadb6249-2976-3146-b7ad-b79bf4809f4d' is connected using session MYSESSION2.

58 ! list tables incaslib="hivelib";

ERROR: The caslib 'hivelib' does not exist in this session.

ERROR: The action stopped due to errors.

59 run;      

 

 

Global-Scope caslib

When a caslib is defined using a CASLIB statement with the GLOBAL option, the caslib is defined as a global-scoped caslib. The global-scoped caslib and associated table could be made available to other users in the CAS server by updating the caslib’s access controls. A group of users or individual users can be included in caslib access controls. If a table is loaded to the CAS server with the PROMOTE option within a global-scoped caslib, the table is available to all users who have access permission to the caslib.  

 

If a table is loaded to the CAS server without the PROMOTE option, within a global-scoped caslib, the table is still personal to the owner and not yet shared with the rest of the users on the CAS server.  

 

The CAS server administrator or authorized user can create session-scoped and global-scoped caslibs, and manage the access controls on caslibs. A table can be promoted from a session caslib to a global caslib.  

 

The following SAS code illustrates the creation of a manual, global-scoped caslib (HiveCaslib) and data load to the CAS server in the same caslib. Notice the CASLIB statement has the GLOBAL option to make it global-scoped and the PROC CASUTIL statement has the PROMOTE option to make it a shared table.

 

CAS mySession host="gatekrbhdp01.gatehadoop.com" SESSOPTS=( CASLIB=casuser TIMEOUT=999 LOCALE="en_US");

/* Assign Std HIVE CASLIB */

caslib hivelib desc="HIVE Caslib"

    datasource=(SRCTYPE="HIVE",SERVER="gatekrbhdp01.gatehadoop.com",    

    HADOOPCONFIGDIR="/opt/sas/hadoop/client_conf/",

    HADOOPJARPATH="/opt/sas/hadoop/client_jar/",

    schema="default",dfDebug=sqlinfo) GLOBAL ;

 

/* Load HIVE tables (In memory) */

proc casutil;

   load casdata="stocks" casout="stocks" outcaslib="hivelib" incaslib="hivelib" PROMOTE ;

quit;  

 

 

After the data is loaded, when the PROC CASUTIL is executed with the list table statement from the same user session, the output displays the caslib as a global-scoped caslib along with associated promoted tables.

 

proc casutil;

    list tables incaslib="hivelib";

run;

 

caslib_2.PNG  

 

Once a global caslib is created, it appears under the list of caslibs on the Configuration tab on the Access Controls window. The CAS administrator can edit and update the user privileges to share the caslibs and associated tables with the rest of the users on the CAS server. A group of users or individual users can be granted access to the global-scoped caslibs on the CAS server. caslib_3.PNG  

 

Once global caslib access control privileges are updated for a user, a new CAS session with the new user (valid user) can access the global CAS table. The following code illustrates the creation of a new CAS session by user sasdemo02 and the access to the CAS table created by user sasdemo01 in the global caslib. Upon execution of the assign _all_ statement, the global caslib is available to user sasdemo02.  

 

CAS mySession2 host="gatekrbhdp01.gatehadoop.com" SESSOPTS=( CASLIB=casuser TIMEOUT=999 LOCALE="en_US");

 

/* Show CASLIB in SAS Studio */

CASLIB _ALL_ ASSIGN;

 

caslib_4.PNG  

The listed CAS data table can be opened by user sasdemo02 from available global caslibs. caslib_5.PNG  

 

User privileges for creating session-scoped and global-scoped caslibs are managed by the CAS administrator using the following screen. A group of users or individual users can be granted permission to create session-scoped and global-scoped caslibs on the CAS server. caslib_6.PNG    

 

Related reading

For more information and documentation about SAS Viya caslibs, see the SAS Cloud Analytics Services Fundamentals.   

Comments

Hi 

 

I have created a global caslib and i am now not able to delete that from ENV manager.

Also i dont see this lib reflecting in the library list. i can see other cas libs both global and session scope.

 

I get this error when i try to create a new caslib using the path or with the same name. i need to as to match with prod.

The caslib *** is a duplicate, parent or subpath of caslib New Connection.

 

How can i drop/delete a global scope library programatically as i dont have cas server monitor.

I dont think that is enabled in our env.

Hi Ramprakash, 

 

You can use  PROC CAS statement to drop a CASLIB, provided you have the permission to drop the CASLIB.

 

PROC CAS ;
table.dropCaslib caslib="<CASLIBNAME>" quiet=TRUE
run;
quit;

 

-Uttam 

Thanks Uttam.

I created a global caslib library using the below code not from ENV manager

caslib ds PATH="/opt/sas/casdata/ds" TYPE=path SESSREF=casauto  GLOBAL SUBDIRS;

 

what is happening is when i use the same path to create a new caslib after dropping this caslib it is not allowing , not sure why.  Different path with the same caslib reference works though. I have to do this though in the end.

@UttamKumar       Hi Uttam,  I am getting started with SAS Viya . I have a question on Path-based CASLIBS. I could not find a proper answer to this question. My question is regarding Path-based CASLIBS. Where exactly (meaning which server) is it path located? In a distributed SAS Viya environment, the user first connects via SAS Studio to SPRE and then starts a CAS Session. Since the SPRE, CAS Controller and each of the Worker Nodes are on separate machines, where exactly is the CASLIB path located? My initial thought was since CASLIB is a CAS server concept, all the paths it refers to are located on the CAS Controller Only but I think that is not always true. Also if the CASLIB Datasource path is on CAS Controller how does the user who connects to SPRE ( via SAS Studio) be able to place a file in the CAS Controller path? Does he have to log in to the CAS Controller machine using a SSH client like WINSCP to place the file in that path before he can create an In-memory table from that file using that CASLIB to do analysis or can the SAS Studio have access to this CAS Controller path ( even though it is a separate machine from SPRE) in some manner so user can just copy a file to the path using SAS Studio and then create an In-memory table using that CASLIB to do analysis on the table? My understanding of this Path concept is still not very clear mainly because multiple machines are involved here and I have never worked in such an architecture. Can you please elaborate on this if possible?

 

My understanding of this  Path concept is still not very clear mainly because multiple machines are involved here and I have never worked on such an architecture.

 

Can you please elaborate on this if possible?

 

 

Appreciate your help.

@pchegoor1 , The physical path for Path-based CASLIB is located to the CAS Controller Server or a NFS drive mounted to CAS Controller server. There are two types of mechanism to load CAS (In-memory) from source data location, one is client side load and other is server side load. 

 

The user interface which can access CAS like SAS 9.4x, SAS studio , Python  etc. are clients and data can be loaded from there too called client side load. In the client side load the data files are available and accessible from client machine only. The file transfer data connector is used in the CAS load action to load these data files.

 

The second one is server side load, where the data files/table available and accessible to CAS controller server and can be loaded to CAS using data connectors like PATH based CASLIB, and Database CASLIB.  

 

To load CAS from client side data using SAS studio, user does not have to physically place the data file onto CAS Controller server. It's just different syntax and mechanism used to load data from client side. Here is an PROC CASUTIL example where a SAS datasets table being loaded into CAS. Notice the "load data= ..." statement rather than  "load casdata=..." statement .   

 

proc casutil ;

   load data=sashelp.prdsale  casout="prdsale"  ;

run ;

 

-Uttam 

Version history
Last update:
‎09-23-2020 04:28 PM
Updated by:
Contributors

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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 Labels
Article Tags