Scénario de test & Cas d'usage
Causal inference analysis and effect estimation.
Discover all actions of causalanalysisCreation of 5000 customer records with confounding variables (Income, Age), a binary treatment (Promo/Control), and a continuous outcome (Spending).
| 1 | |
| 2 | DATA mycas.marketing_campaign; |
| 3 | call streaminit(12345); |
| 4 | DO i = 1 to 5000; |
| 5 | age = rand('NORMAL', 35, 10); |
| 6 | income = rand('LOGNORMAL', 10, 0.5); |
| 7 | prob_promo = logistic(-2 + 0.05*age + 0.00001*income); |
| 8 | IF rand('UNIFORM') < prob_promo THEN treatment = 'Promo'; |
| 9 | ELSE treatment = 'Control'; |
| 10 | spending = 100 + 50*(treatment='Promo') + 2*age + 0.001*income + rand('NORMAL', 0, 50); |
| 11 | OUTPUT; |
| 12 | END; |
| 13 | |
| 14 | RUN; |
| 15 |
| 1 | |
| 2 | PROC CAS; |
| 3 | regression.glm TABLE={name='marketing_campaign'}, class={'treatment'}, model={depvar='spending', effects={'treatment', 'age', 'income'}}, store={name='outcome_mdl', replace=true}; |
| 4 | logistic TABLE={name='marketing_campaign'}, class={'treatment'}, model={depvar='treatment', effects={'age', 'income'}}, store={name='ps_model', replace=true}; |
| 5 | logistic.score TABLE={name='marketing_campaign'}, restore={name='ps_model'}, casout={name='scored_data', replace=true}, copyVars={'spending', 'treatment', 'age', 'income'}; |
| 6 | |
| 7 | RUN; |
| 8 |
| 1 | |
| 2 | PROC CAS; |
| 3 | causalanalysis.caEffect TABLE={name='scored_data'}, method='AIPW', treatVar={name='treatment'}, outcomeVar={name='spending', type='CONTINUOUS'}, outcomeModel={restore={name='outcome_mdl'}, predName='P_spending'}, pom={{trtLev='Promo', trtProb='P_treatmentPromo'}, {trtLev='Control', trtProb='P_treatmentControl'}}, difference={{evtLev='Promo', refLev='Control'}}, inference=true, alpha=0.05; |
| 4 | |
| 5 | RUN; |
| 6 |
The action successfully calculates the Potential Outcome Means (POM) for Promo and Control. It produces the 'CausalEffects' table showing the ATE (Average Treatment Effect) of the promotion on spending, including Standard Errors and 95% Confidence Intervals, confirming the 'Doubly Robust' nature of the estimation.