table

addCaslib

Description

Adds a new caslib to enable access to a data source. A caslib is an in-memory space to hold tables, access control lists, and data source information. Caslibs provide a way to organize in-memory tables and to manage access to data. All data is available to CAS through caslibs, and all operations in CAS that use tables are performed with caslibs.

table.addCaslib <result=results> <status=rc> / activeOnAdd=TRUE | FALSE, createDirectory=TRUE | FALSE, dataSource={srcType="ADLS" | "BIGQUERY" | "CAS" | "CLOUDDEX" | "DB2" | "DEFAULT" | "DNFS" | "ESP" | "FEDSVR" | "GCS" | "GREENPLUM" | "HADOOP" | "HANA" | "HDFS" | "IMPALA" | "INFORMIX" | "JDBC" | "LASR" | "MONGODB" | "MYSQL" | "NETEZZA" | "ODBC" | "ORACLE" | "PATH" | "POSTGRES" | "REDSHIFT" | "S3" | "SAPIQ" | "SFORCE" | "SINGLESTORE" | "SINGLESTORE_STANDARD" | "SNOWFLAKE" | "SPARK" | "SPDE" | "SQLSERVER" | "TERADATA" | "VERTICA" | "YELLOWBRICK", srcType-specific-parameters}, description="string", hidden=TRUE | FALSE, name="string", path="string", permission="GROUPREAD" | "GROUPWRITE" | "GROUPWRITEPUBLICREAD" | "PRIVATE" | "PUBLICREAD" | "PUBLICWRITE" | integer, session=TRUE | FALSE, subDirectories=TRUE | FALSE, tableRedistUpPolicy="DEFER" | "NOREDIST" | "REBALANCE", transient=TRUE | FALSE;
Settings
ParameterDescription
activeOnAddWhen set to True, the new caslib becomes the active caslib. Default: TRUE.
createDirectoryWhen set to True, the caslib directory will be created. Default: FALSE.
dataSourceSpecifies the data source type and type-specific parameters. The value for srcType determines which other parameters are applicable.
descriptionSpecifies a description for the caslib.
hiddenWhen set to True, the caslib will be a hidden caslib. Default: FALSE.
nameSpecifies the name of the caslib to add. This is a required parameter.
pathSpecifies data source-specific information. For PATH and DNFS types, this is a file system path.
permissionSpecifies the host access controls on the caslib when directory creation is requested. By default, permissions are set by the umask of the session process.
sessionWhen set to True, the caslib is scoped to the current session only. Tables loaded in this session cannot be accessed from other sessions. If False, the caslib is visible to other sessions, subject to access controls. Default: TRUE.
subDirectoriesWhen set to True, tables and files in subdirectories of the path are accessible from the caslib. Default: FALSE.
tableRedistUpPolicySpecifies the default Table Redistribution Policy for tables in this caslib when the number of worker pods increases.
transientWhen set to True, the caslib will be a transient caslib, meaning it will not persist after the session ends. Default: FALSE.
Data Preparation View data prep sheet
Data Creation for Examples

No specific data creation is needed for the addCaslib action itself, as it is used to define a data source location. The examples assume that the specified paths or database connections are valid.

Copied!
1/* No
2data creation step is necessary for addCaslib. Ensure the target path or database exists. */

Examples

This example demonstrates how to add a basic caslib named 'MyPathCaslib' that points to a directory on the file system. This is the most common type of caslib for accessing files like SASHDAT, CSV, or Parquet files. The 'session=false' parameter makes it available to other sessions.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3TABLE.addCaslib / name="MyPathCaslib" path="/path/to/your/
4data" dataSource={srcType="PATH"}
5SESSION=false;
6 
7RUN;
8 
9QUIT;
10 
Result :
The 'MyPathCaslib' caslib is successfully created and is now available for loading data. A confirmation note will appear in the SAS log indicating the caslib was added.

This example shows how to add a caslib to connect to an Oracle database. It specifies the data source type as 'ORACLE' and includes necessary connection parameters like the server path, user, password, and schema. This allows CAS to directly query and load data from the Oracle database.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3TABLE.addCaslib / name="MyOracleCaslib" dataSource={srcType="ORACLE", path="oracle-server.example.com", user="myuser", password="mypassword", schema="myschema"}
4SESSION=false;
5 
6RUN;
7 
8QUIT;
9 
Result :
The 'MyOracleCaslib' is created, establishing a connection to the specified Oracle database. Tables within the 'myschema' schema are now accessible through this caslib. A confirmation note will appear in the SAS log.

This example creates a session-level caslib named 'TempData'. The 'session=true' parameter ensures the caslib is automatically dropped when the session ends. The 'subDirectories=true' option allows access to files in subfolders of the specified path, which is useful for organizing large datasets.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3TABLE.addCaslib / name="TempData" path="/tmp/cas/tempdata" dataSource={srcType="PATH"}
4SESSION=true subDirectories=true;
5 
6RUN;
7 
8QUIT;
9 
Result :
A temporary, session-scoped caslib named 'TempData' is created. Files within '/tmp/cas/tempdata' and its subdirectories can be loaded. The caslib will be automatically removed at the end of the user's session.

FAQ

What is the purpose of the addCaslib action?
What is the main required parameter for the addCaslib action?
What happens if I provide an invalid path when using the addCaslib action?
How can I create a temporary caslib that only exists for my current session?
What are some of the data source types ('srcType') supported by the addCaslib action?
How can I make a newly added caslib the active one immediately?

Associated Scenarios

Use Case
Standard Case: Marketing Analyst Accessing Customer Data on S3

A marketing team needs to analyze new customer campaign data stored in a CSV file within an Amazon S3 bucket. The goal is to create a session-scoped caslib to load and analyze t...

Use Case
Volume Test: Global Data Lake Caslib with Subdirectory Access

A data engineering team is establishing a central data lake on a Distributed Network File System (DNFS). The caslib must be global (not session-scoped), persistent, and provide ...

Use Case
Edge Case: Handling Invalid Paths and Directory Creation

A new user is attempting to create a personal, transient caslib for temporary data storage. They first specify a path that does not exist, testing the system's behavior. Then, t...