Scénario de test & Cas d'usage
Configuration of session properties.
Discover all actions of sessionPropCreate two distinct format libraries (Marketing and Fraud) with a conflicting format name '$STATUSFMT'.
| 1 | /* 1. Marketing Formats */ |
| 2 | PROC FORMAT; |
| 3 | value $statusfmt 'A'='Active Customer' 'I'='Inactive Customer'; |
| 4 | RUN; |
| 5 | DATA work.mktg_ctl; SET sashelp.vformat; where fmtname='$STATUSFMT'; RUN; |
| 6 | |
| 7 | /* 2. Fraud Formats */ |
| 8 | PROC FORMAT; |
| 9 | value $statusfmt 'A'='Approved' 'D'='Denied'; |
| 10 | RUN; |
| 11 | DATA work.fraud_ctl; SET sashelp.vformat; where fmtname='$STATUSFMT'; RUN; |
| 12 | |
| 13 | /* 3. Load control tables to CAS */ |
| 14 | PROC CASUTIL; |
| 15 | load DATA=work.mktg_ctl outcaslib='casuser' casout='mktg_formats_table' replace; |
| 16 | load DATA=work.fraud_ctl outcaslib='casuser' casout='fraud_formats_table' replace; |
| 17 | QUIT; |
| 18 | |
| 19 | /* 4. Create test data */ |
| 20 | DATA work.test_data; INPUT status_code $; DATALINES; |
| 21 | A |
| 22 | I |
| 23 | D |
| 24 | ; RUN; |
| 25 | PROC CASUTIL; load DATA=work.test_data outcaslib='casuser' casout='status_codes' replace; QUIT; |
| 1 | PROC CAS; |
| 2 | sessionProp.addFmtLib / caslib='casuser' name='mktg_formats_table' fmtLibName='MktgLib'; |
| 3 | sessionProp.addFmtLib / caslib='casuser' name='fraud_formats_table' fmtLibName='FraudLib' fmtSearch='INSERT'; |
| 4 | RUN; |
| 5 | |
| 6 | /* Apply format - should use Fraud's definition */ |
| 7 | fedsql.execDirect / query='select status_code, put(status_code, \'$STATUSFMT.\') as FormattedStatus from casuser.status_codes'; |
| 8 | RUN; |
| 1 | PROC CAS; /* Assumes a new session */ |
| 2 | sessionProp.addFmtLib / caslib='casuser' name='fraud_formats_table' fmtLibName='FraudLib'; |
| 3 | sessionProp.addFmtLib / caslib='casuser' name='mktg_formats_table' fmtLibName='MktgLib' fmtSearch='APPEND'; |
| 4 | RUN; |
| 5 | |
| 6 | /* Apply format - should use Fraud's definition */ |
| 7 | fedsql.execDirect / query='select status_code, put(status_code, \'$STATUSFMT.\') as FormattedStatus from casuser.status_codes'; |
| 8 | RUN; |
For Step 1, the result set must show the Fraud definitions: 'A' becomes 'Approved', 'D' becomes 'Denied', and 'I' remains 'I' (unformatted). This proves `fmtSearch='INSERT'` placed the 'FraudLib' at the start of the search path. For Step 2, the result set must also show the Fraud definitions. This proves that with `APPEND` (the default), the first library loaded ('FraudLib') is found first in the search path, and the conflicting format in the second library is ignored.