Action Principale : caEffect
| 1 | DATA casuser.CausalData; |
| 2 | DO CustomerID = 1 to 1000; |
| 3 | Age = 20 + floor(rand('uniform')*50); |
| 4 | Income = 30000 + floor(rand('uniform')*70000); |
| 5 | IF rand('uniform') < 0.4 + 0.005*(Age-45) - 0.00001*(Income-65000) THEN Campaign = 'Test'; |
| 6 | ELSE Campaign = 'Control'; |
| 7 | IF Campaign = 'Test' THEN Purchase = (rand('uniform') < 0.6 + 0.002*(Age-20)); |
| 8 | ELSE Purchase = (rand('uniform') < 0.3 - 0.001*(Income-30000)/10000); |
| 9 | OUTPUT; |
| 10 | END; |
| 11 | RUN; |
| 12 | |
| 13 | PROC LOGISTIC DATA=casuser.CausalData outest=casuser.psmodel_est noprint; |
| 14 | model Campaign(event='Test') = Age Income; |
| 15 | OUTPUT out=casuser.PropScores p=prop_Test; |
| 16 | RUN; |
| 17 | |
| 18 | DATA casuser.PropScores; |
| 19 | SET casuser.PropScores; |
| 20 | prop_Control = 1 - prop_Test; |
| 21 | RUN; |
| 22 | |
| 23 | PROC LOGISTIC DATA=casuser.CausalData outest=casuser.outcomemodel_est noprint; |
| 24 | class Campaign; |
| 25 | model Purchase(event='1') = Age Income Campaign; |
| 26 | store casuser.OutcomeModel; |
| 27 | RUN; |
| 28 | |
| 29 | DATA casuser.ScoringData_Test; |
| 30 | SET casuser.CausalData; |
| 31 | Campaign = 'Test'; |
| 32 | RUN; |
| 33 | |
| 34 | DATA casuser.ScoringData_Control; |
| 35 | SET casuser.CausalData; |
| 36 | Campaign = 'Control'; |
| 37 | RUN; |
| 38 | |
| 39 | PROC PLM restore=casuser.OutcomeModel; |
| 40 | score DATA=casuser.ScoringData_Test out=casuser.Pred_Test predicted=p_Test; |
| 41 | RUN; |
| 42 | |
| 43 | PROC PLM restore=casuser.OutcomeModel; |
| 44 | score DATA=casuser.ScoringData_Control out=casuser.Pred_Control predicted=p_Control; |
| 45 | RUN; |
| 46 | |
| 47 | DATA casuser.FinalInput; |
| 48 | MERGE casuser.PropScores(in=a) |
| 49 | casuser.Pred_Test(keep=CustomerID p_Test) |
| 50 | casuser.Pred_Control(keep=CustomerID p_Control); |
| 51 | BY CustomerID; |
| 52 | IF a; |
| 53 | RUN; |