table alterTable

Data Governance and PII Masking for Financial Reporting

Scénario de test & Cas d'usage

Business Context

A financial analyst needs to create a summary report on customer transactions. The source table contains sensitive Personally Identifiable Information (PII) and other irrelevant details. The task is to create a sanitized version of the table by dropping sensitive columns and keeping only the essential data for the report.
About the Set : table

Loading, saving, and managing in-memory tables.

Discover all actions of table
Data Preparation

Create a customer transaction table containing PII (email, phone) and other operational columns.

Copied!
1DATA casuser.TRANSACTIONS_RAW;
2 LENGTH cust_id 8 acct_num $16 trans_id $12 email $30 phone $15 trans_code $4 amount 8;
3 FORMAT trans_date datetime20.;
4 INFILE DATALINES delimiter=',';
5 INPUT cust_id acct_num $ trans_id $ email $ phone $ trans_date trans_code $ amount;
6 DATALINES;
7101,ACC-555-1234,T001,j.doe@example.com,555-123-4567,27NOV2025:10:30:00,PAY,150.75
8102,ACC-555-9876,T002,s.smith@example.com,555-987-6543,27NOV2025:11:05:00,DEP,2000.00
9101,ACC-555-1234,T003,j.doe@example.com,555-123-4567,27NOV2025:14:22:00,XFR,300.00
10;
11RUN;

Étapes de réalisation

1
Load the raw transaction data into CAS.
Copied!
1 
2PROC CAS;
3TABLE.loadTable / caslib='casuser' path='TRANSACTIONS_RAW.sashdat' casout={name='transactions_raw', replace=true};
4RUN;
5 
2
Use the top-level 'drop' parameter to immediately remove sensitive PII columns ('email', 'phone') for compliance.
Copied!
1PROC CAS;
2 TABLE.alterTable /
3 caslib='casuser'
4 name='transactions_raw'
5 drop={'email', 'phone'};
6RUN;
3
Use the 'keep' parameter to create the final reporting table, retaining only the essential columns for analysis and dropping all others implicitly.
Copied!
1PROC CAS;
2 TABLE.alterTable /
3 caslib='casuser'
4 name='transactions_raw'
5 keep={'cust_id', 'trans_date', 'amount'}
6 rename='REPORT_TRANSACTIONS';
7RUN;
4
Verify that only the 'kept' columns exist in the final table.
Copied!
1 
2PROC CAS;
3TABLE.columnInfo / TABLE='REPORT_TRANSACTIONS';
4RUN;
5 

Expected Result


The final table, named 'REPORT_TRANSACTIONS', must contain only three columns: 'cust_id', 'trans_date', and 'amount'. All other columns, including the PII and operational ones, must have been successfully dropped.