table addCaslib

Standard Case: Marketing Analyst Accessing Customer Data on S3

Scénario de test & Cas d'usage

Business Context

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 this data without making it permanently available to other users on the CAS server.
About the Set : table

Loading, saving, and managing in-memory tables.

Discover all actions of table
Data Preparation

This scenario assumes an S3 bucket exists and contains a 'customer_campaign.csv' file. No data step is needed, but the S3 credentials (key, secret) and bucket details must be configured in the environment or specified directly.

Copied!
1/* Pre-requisite: An S3 bucket 'my-marketing-bucket' exists in the 'us-east-1' region and contains the file '
2data/customer_campaign.csv'. AWS credentials must be configured for the CAS server. */

Étapes de réalisation

1
Add a session-scoped caslib to connect to the S3 data source. The caslib should become active immediately.
Copied!
1PROC CAS;
2 TABLE.addCaslib /
3 name="MarketingS3"
4 description="Marketing Campaign Data from S3"
5 dataSource={srcType="S3",
6 accessKeyId="YOUR_AWS_ACCESS_KEY_ID",
7 secretAccessKey="YOUR_AWS_SECRET_ACCESS_KEY",
8 bucket="my-marketing-bucket",
9 region="us-east-1"
10 }
11 SESSION=true
12 activeOnAdd=true;
13RUN; QUIT;
2
Verify that the caslib was added and is now the active caslib for the session.
Copied!
1PROC CAS;
2 TABLE.caslibInfo / caslib="MarketingS3";
3 SESSION.sessionStatus;
4RUN; QUIT;
3
Attempt to load the CSV file from the S3 bucket into an in-memory table.
Copied!
1PROC CAS;
2 TABLE.loadTable /
3 caslib="MarketingS3"
4 path="data/customer_campaign.csv"
5 casOut={name="campaign_data", caslib="MarketingS3", replace=true};
6RUN; QUIT;

Expected Result


The 'MarketingS3' caslib is successfully created and set as the active caslib. The caslibInfo action confirms its existence and S3 data source configuration. The loadTable action successfully loads 'customer_campaign.csv' into a CAS table named 'campaign_data'. The caslib will be automatically dropped at the end of the session.