SAS Macro Programs used for Marketing purpose
This repository contains a list of SAS macro-programs that I have developed for marketing purpose, such as :
- formating and preparing data for modeling
- applying cross-validation modeling
- analysing models goodness-of-fit
- projecting modeling results from new data
filename x "path_to_sasmarketing\sasmarketing\*.sas"";
%include x/source2;
proc import datafile = "&DIR_DSRC\train.csv"
out = titanic
replace
dbms = CSV;
run;
data titanic;
set titanic;
if Survived = 1 then
Survived2="Survécu";
else Survived2 = "Mort";
run;
%let var_x= Age Pclass Fare SibSp Parch PassengerId;
%SYMDEL COVARFIN;
%AICoptSW(
*Jeu de données en entrée;
indat=titanic,
*la variable cible binaire (1/0) à prédire;
y=Survived,
*Variables prédicteurs/descripteurs ;
x=&var_x,
* nombre qui détermine la reproductibilité de l'échantillonnage de validation croisée ;
seed=1,
* spécifie le nombre de sous-échantillons distincts pour réaliser la validation croisée ;
fold=5,
* nombre de fois que le processus de validation croisée est répété ;
repeats=1
);
%SYMDEL COVARFIN;
data DTRV.varfreq_fin;
length cat $10000;
do until (last._name_);
set DTRV.varfreq_wide(where =(freq > 0.9));
by _name_ notsorted;
cat=catx(' ',cat,varlist);
end;
run;
proc sql noprint;
select cat
into :COVARFIN separated by ' '
from DTRV.VARFREQ_FIN;
quit;
%put &COVARFIN;
%cvAUC (y=Survived, covars=&COVARFIN, fold=5, repeats=1);
* Représentation graphique des performance des modèles;
ods graphics / width=700px height=480px;
proc sgplot data=dsas.res_dec;
vbox tx_cible / category=rang group=target clusterwidth=0.5;
xaxis display=(noline nolabel noticks);
yaxis display=(noline noticks) grid;
run;
ods graphics / width=700px height=480px;
proc sgplot data=dsas.res_auc;
vbox auc / category=target clusterwidth=0.5;
xaxis display=(noline nolabel noticks);
yaxis display=(noline noticks) grid;
run;
data datapred; set titanic; run;
%mod_pred(y=Survived, covars=&COVARFIN, newdata=datapred,repeats=1, fold=5, by=PassengerId);