Scénario de test & Cas d'usage
Configuration of session properties.
Discover all actions of sessionPropCreate a large control data set for risk formats and save it as a SASHDAT file on the server's file system.
| 1 | /* Create risk formats */ |
| 2 | PROC 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'; |
| 5 | RUN; |
| 6 | |
| 7 | /* Create control data set */ |
| 8 | DATA work.risk_formats_ctl; |
| 9 | SET sashelp.vformat; |
| 10 | where fmtname in ('RISKSCOREFMT', 'TXNTYPE'); |
| 11 | RUN; |
| 12 | |
| 13 | /* Load to CAS to save as SASHDAT */ |
| 14 | PROC 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; |
| 18 | QUIT; |
| 1 | PROC 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; |
| 9 | RUN; |
| 1 | /* Start a new session; no addFmtLib call is made here */ |
| 2 | PROC 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 |
| 6 | 2 T03 |
| 7 | 5 T02 |
| 8 | ; run;'; |
| 9 | RUN; |
| 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'; |
| 14 | RUN; |
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.