?> addCaslibSubdir - WeAreCAS
table

addCaslibSubdir

Description

The `addCaslibSubdir` action creates a new subdirectory within the physical path of an existing caslib. This is particularly useful for organizing data sources and other files within a caslib's storage without needing direct file system access. The action allows specifying permissions for the new subdirectory, ensuring proper access control from the moment of creation.

table.addCaslibSubdir { caslib="string", path="string", permission="string" | integer };
Settings
ParameterDescription
caslibSpecifies the name of the caslib where the subdirectory will be created. This parameter is required to identify the target storage location.
pathSpecifies the name of the subdirectory to create. The path is relative to the root directory of the specified caslib. This parameter is mandatory.
permissionSpecifies the file system permissions for the new subdirectory using either a descriptive string (e.g., 'PUBLICREAD', 'PRIVATE') or an octal integer representation. If omitted, the default permissions are determined by the umask of the CAS server process.
Data Preparation
Setting Up a Path-Based Caslib

Before creating a subdirectory, we first need a caslib. This code sets up a new caslib named 'myCaslib' pointing to a specific path on the CAS server's file system. Ensure the specified path exists and the server has the necessary permissions.

proc cas; caslib myCaslib path='/cas/data/casuser' dataSource={srcType='path'}; run;

Examples

This example demonstrates the most basic usage of the `addCaslibSubdir` action. It creates a new subdirectory named 'new_data_folder' inside the 'myCaslib' caslib with default permissions.

SAS® / CAS Code
Copied!
1PROC CAS; TABLE.addCaslibSubdir / caslib='myCaslib' path='new_data_folder'; RUN;
Result :
The action will return a success status, and a new directory named 'new_data_folder' will be created in the '/cas/data/casuser' directory on the server.

This example creates a subdirectory named 'shared_reports' within the 'myCaslib' caslib. It explicitly sets the permissions to 'GROUPWRITEPUBLICREAD', which allows the owner and the group to read and write, while others can only read.

SAS® / CAS Code
Copied!
1PROC CAS; TABLE.addCaslibSubdir / caslib='myCaslib' path='shared_reports' permission='GROUPWRITEPUBLICREAD'; RUN;
Result :
A new directory 'shared_reports' is created. The file system permissions will be set to 775 (rwxrwxr-x), allowing read/write for the owner and group, and read-only for others.

After creating a subdirectory, you can verify its existence by using the `fileInfo` action. This example first creates a directory 'project_alpha' and then lists the contents of the caslib's root to confirm the new directory is present.

SAS® / CAS Code
Copied!
1PROC CAS; TABLE.addCaslibSubdir / caslib='myCaslib' path='project_alpha';
2 TABLE.fileInfo / caslib='myCaslib'; RUN;
Result :
The output will first show the success message for the `addCaslibSubdir` action. The subsequent `fileInfo` result table will list all files and directories in 'myCaslib', including the newly created 'project_alpha' directory.

FAQ

What is the purpose of the `addCaslibSubdir` action?
What is the required parameter for the `addCaslibSubdir` action?
What does the `name` parameter specify in the `addCaslibSubdir` action?
What options are available for the `permission` parameter?

Associated Scenarios

Use Case
Standard Use Case: Marketing Campaign Folder Organization

A marketing department needs to structure its data for a new campaign. They require a dedicated, secure subdirectory within their main caslib to store customer lists, creative a...

Use Case
Edge Case: Data Governance and Security Validation

A data governance team is stress-testing the CAS environment to ensure system integrity and security. They must verify that the `addCaslibSubdir` action fails gracefully and pro...

Use Case
Performance & Automation: Daily Data Ingestion Folders

An automated ETL process needs to create a unique subdirectory for each day's data load within an 'ingestion' caslib. This scenario tests the action's performance and reliabilit...