?>Array ( [id] => 97 ) Standard Case: Customer Risk Profile Segmentation - WeAreCAS
sessionProp addFormat

Standard Case: Customer Risk Profile Segmentation

Scénario de test & Cas d'usage

Contexto empresarial

A financial institution needs to classify its customers into risk categories based on their credit score. This allows for tailored product offerings and risk management. The format should be simple, robust, and easily updatable.
Preparación de datos

Creation of a small customer dataset with credit scores. This table will be loaded into CAS to test the format application.

¡Copiado!
1DATA casuser.CustomerScores;
2 INFILE DATALINES;
3 INPUT CustomerID Score;
4 DATALINES;
5101 820
6102 745
7103 650
8104 580
9105 999
10106 350
11;
12RUN;

Étapes de réalisation

1
Create a new format library named 'RiskFormats' and ensure it's clean by using the 'replace' option.
¡Copiado!
1PROC CAS;
2 ACTION sessionProp.addFmtLib /
3 fmtLibName='RiskFormats',
4 replace=true;
5RUN;
6QUIT;
2
Define a numeric format 'ScoreFmt' to map credit scores to risk labels. The 'other' keyword handles unexpected values.
¡Copiado!
1PROC CAS;
2 ACTION sessionProp.addFormat /
3 fmtLibName='RiskFormats'
4 fmtName='ScoreFmt'
5 ranges={'300-579=High Risk', '580-669=Fair Risk', '670-799=Good Risk', '800-850=Excellent', 'other=Review'};
6RUN;
7QUIT;
3
Apply the newly created format to the 'Score' column and display the results to verify the mapping.
¡Copiado!
1PROC casutil;
2 load DATA=casuser.CustomerScores outcaslib='casuser' casout='CustomerScores' replace;
3QUIT;
4PROC CAS;
5 TABLE.fetch /
6 TABLE='CustomerScores',
7 FORMAT=true,
8 vars={'CustomerID', 'Score'},
9 formatDef={name='Score', FORMAT='ScoreFmt'};
10RUN;
11QUIT;

Resultado esperado


The final fetched table should display a new formatted column for 'Score'. For example, customer 101 with a score of 820 should display 'Excellent', customer 103 with 650 should display 'Fair Risk', and customer 105 with 999 should display 'Review', demonstrating the 'other' keyword works correctly.