Scénario de test & Cas d'usage
Simulating customer spending data across different categories.
| 1 | |
| 2 | DATA casuser.customers; |
| 3 | call streaminit(123); |
| 4 | DO client_id = 1 to 1000; |
| 5 | groceries = rand('Normal', 500, 50); |
| 6 | travel = groceries * 0.5 + rand('Normal', 100, 20); |
| 7 | entertainment = rand('Normal', 200, 30); |
| 8 | utilities = rand('Normal', 150, 10); |
| 9 | OUTPUT; |
| 10 | END; |
| 11 | |
| 12 | RUN; |
| 13 |
| 1 | |
| 2 | PROC CAS; |
| 3 | pca.eig / TABLE={name='customers', caslib='casuser'} inputs={'groceries', 'travel', 'entertainment', 'utilities'} n=2 prefix='Pattern' code={casOut={name='score_code', caslib='casuser', replace=true}} outStat={casOut={name='pca_stats', caslib='casuser', replace=true}}; |
| 4 | |
| 5 | RUN; |
| 6 |
| 1 | |
| 2 | DATA casuser.scored_customers; |
| 3 | SET casuser.customers; |
| 4 | %include casuser.score_code; |
| 5 | |
| 6 | RUN; |
| 7 |
The action should successfully identify 2 principal components explaining the variance in spending. The 'pca_stats' table should contain eigenvalues. The scoring step should add 'Pattern1' and 'Pattern2' columns to the customer table.