Fiche Data Prep

Action Principale : caEffect

Code de préparation

Script en attente de validation
Copié !
1DATA casuser.CausalData;
2DO 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;
10END;
11RUN;
12 
13PROC LOGISTIC DATA=casuser.CausalData outest=casuser.psmodel_est noprint;
14 model Campaign(event='Test') = Age Income;
15 OUTPUT out=casuser.PropScores p=prop_Test;
16RUN;
17 
18DATA casuser.PropScores;
19 SET casuser.PropScores;
20 prop_Control = 1 - prop_Test;
21RUN;
22 
23PROC LOGISTIC DATA=casuser.CausalData outest=casuser.outcomemodel_est noprint;
24 class Campaign;
25 model Purchase(event='1') = Age Income Campaign;
26 store casuser.OutcomeModel;
27RUN;
28 
29DATA casuser.ScoringData_Test;
30 SET casuser.CausalData;
31 Campaign = 'Test';
32RUN;
33 
34DATA casuser.ScoringData_Control;
35 SET casuser.CausalData;
36 Campaign = 'Control';
37RUN;
38 
39PROC PLM restore=casuser.OutcomeModel;
40 score DATA=casuser.ScoringData_Test out=casuser.Pred_Test predicted=p_Test;
41RUN;
42 
43PROC PLM restore=casuser.OutcomeModel;
44 score DATA=casuser.ScoringData_Control out=casuser.Pred_Control predicted=p_Control;
45RUN;
46 
47DATA 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;
53RUN;
Actions utilisant ce script
  • causalanalysis caEffect En cours
  • Aucune autre action n'utilise ce script exact.