sessionProp addFmtLib

Global Scope & Replacement: Centralized Financial Transaction Risk Formats

Scénario de test & Cas d'usage

Business Context

A financial institution maintains a centrally managed, large set of formats for categorizing transaction risk. This library must be available to all data scientists and analysts across all CAS sessions for consistency. An administrator is responsible for updating this library daily. This scenario tests loading a format from a server path, promoting it to global scope, and replacing the previous version.
About the Set : sessionProp

Configuration of session properties.

Discover all actions of sessionProp
Data Preparation

Create a large control data set for risk formats and save it as a SASHDAT file on the server's file system.

Copied!
1/* Create risk formats */
2PROC FORMAT;
3 value riskscorefmt 1-3='Low' 4-7='Medium' 8-10='High';
4 value $txntype 'T01'='Wire Transfer' 'T02'='ACH' 'T03'='Card Payment' other='Misc';
5RUN;
6 
7/* Create control data set */
8DATA work.risk_formats_ctl;
9 SET sashelp.vformat;
10 where fmtname in ('RISKSCOREFMT', 'TXNTYPE');
11RUN;
12 
13/* Load to CAS to save as SASHDAT */
14PROC CASUTIL;
15 load DATA=work.risk_formats_ctl outcaslib='casuser' casout='risk_formats_table' replace;
16 /* This path assumes /cas/data/casuser is a valid path on the CAS controller */
17 save casdata='risk_formats_table' incaslib='casuser' outpath='/cas/data/casuser/global_risk_formats.sashdat' replace;
18QUIT;

Étapes de réalisation

1
As an administrator, add the format library from the server path, promoting it to global scope and ensuring any previous version is replaced.
Copied!
1PROC CAS;
2 /* An admin might need to assume a role first in a real secured environment */
3 /* accessControl.assumeRole / role='CASHostAccount'; */
4 sessionProp.addFmtLib /
5 path='/cas/data/casuser/global_risk_formats.sashdat'
6 fmtLibName='GlobalRiskLib'
7 promote=true
8 replace=true;
9RUN;
2
In a NEW, separate CAS session (simulating a different user), verify that the global formats are available without explicitly loading them.
Copied!
1/* Start a new session; no addFmtLib call is made here */
2PROC CAS;
3 /* Create a sample table to test the formats */
4 datastep.runCode /
5 code='data casuser.transactions; length transaction_type $ 3; input risk_score transaction_type; datalines; 9 T01
62 T03
75 T02
8; run;';
9RUN;
10 
11 /* Check if formats are applied */
12 fedsql.execDirect /
13 query='select put(risk_score, RISKSCORefmt.) as Risk_Category, put(transaction_type, $TXNTYPE.) as Transaction_Description from casuser.transactions';
14RUN;

Expected Result


The log for step 1 will show a note confirming the 'GlobalRiskLib' was successfully added and promoted. The `fedsql.execDirect` query in step 2 (run in a new session) must execute successfully and return a result set with the formatted values ('High', 'Wire Transfer'), ('Low', 'Card Payment'), etc. This proves the format library is in the global scope and accessible to new sessions without further action.