Skip to content
Extraits de code Groupes Projets

Comparer les révisions

Les modifications sont affichées comme si la révision source était fusionnée avec la révision cible. En savoir plus sur la comparaison des révisions.

Source

Sélectionner le projet cible
No results found

Cible

Sélectionner le projet cible
  • la-quadrature-du-net/algo-et-controle/caf
1 résultat
Afficher les modifications
Validations sur la source (2)
Impossible d'afficher diff de source : il est trop volumineux. Options pour résoudre ce problème : voir le blob.
/******************************************************************/
/*PROJET : MDR SCORE DATAMINING */
/*NOMPGM : calcul_score_modele.sas */
/*AUTEUR : xxxx */
/*DATECRE : 09/2014 */
/*DATEMAJ : */
/*OBJET : Requte pour calcul score datamining DE : modle septembre 2014 */
/* : lanc par lance_calcul_score */
/*MOTCLE : */
/******************************************************************/
/**************************************************************************************************/
/***** Requte de scoring ***********/
/***** du modle Datamining DE 2014 ***********/
/***** ***********/
/***** ***********/
/**************************************************************************************************/
%let limit_test = (matricul ne .);
option obs=max compress = no ;
options nomprint nosymbolgen ;
%global m1 mvDTREFFRE /* m1 = dernier mois trait*/ ;
%macro DM_DE;
/* INITIALISATION DES 18 MOIS A TRAITER */
%macro mp_18mmaa ;
/* ATTENTION LES MOIS VONT DU PLUS RECENT AU PLUS ANCIEN */
data _null_ ;
set basenat.xdref (where = (NOMTAB = 'FREMM')) ;
/******************* POUR FORCER LE MOIS DE REFERENCE ********************/
/*DFREF = MDY(8,1,2014) ;*/
/**************************************************************************/
Call symput("mvDTFREMM", DFREF) ;
run ;
data _null_ ;
set basefrm.datall ;
call symput ("mvDTBASEFRM", DTBASE) ;
run ;
data _null_ ;
%do i = 1 %to 18 ;
nbMOIS = /*-18 + */ &i. ;
DDREF&i = INTnx ("MONTH", &mvDTFREMM., - nbMois +1 , "beginning") ;
mmaa&i. =
compress(put(month(DDREF&i.),z2.)!!SUBSTR(put(year(DDREF&i.),z4.),3,2)) ;
%global m&i. ;
call symput( "m&i.", mmaa&i. ) ;
%end ;
run ;
%mend ;
%mp_18mmaa ;
/*Modification PAC nov2015 : ajout de conditions sur l'existence des variables PAC*/
proc contents DATA = basestat.fre&m1. noprint out = WORK.temp ;
run ;
proc sql noprint;
select count(*) into: mv_pres_MTOTFOY
from temp
where name="MTOTFOY1";
quit;
proc sql noprint;
select count(*) into: mv_pres_DTINCOAC
from temp
where name="DTINCOAC";
quit;
proc sql noprint;
select count(*) into: mv_pres_PPAVERS
from temp
where name="PPAVERS";
quit;
proc sql noprint;
select count(*) into: mv_pres_RSAACT
from temp
where name="RSAACT";
quit;
proc sql noprint;
select count(*) into: mv_pres_RESTRRSA
from temp
where name="RESTRRSA";
quit;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * */
/* Sommaire du programme (rappel des titres dans le
pg) */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * */
/*Partie 1: Constitution de la base d information datamining (le programme est
ordonn par catgorie d'information)
a)Initialisation de la table pour alimentation au fur et mesure par
jointures successives
b)Catgorie d'indicateurs : Historique FRE indus
antrieurs,+adresse,activit,abattement et neutram (entrepts CAF seulement)
c)Catgorie d'indicateurs : Historique gestion dossier sur conseil mtier
(FG...) (entrepts CAF seulement)
d)Catgorie d'indicateurs : Historique de contact (entrepts CAF seulement)
e)Catgorie d'indicateurs : DIVERS SUR BASE INFOCENRE (entrepts CAF
seulement)
f)Catgorie d'indicateurs : HISTORIQUE SITUATION CONTROL et VERIF (donnes
disponibles dans le ALLNAT au CSN)
h)Catgorie d'indicateurs : DONNEES SDP
i)Catgorie d'indicateurs : SITUATION DOSSIER FRE SUR LA DATE DE REFERENCE
(donnes disponibles dans le ALLNAT au CSN)
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * */
/**********************************************************************************************************************/
/**********************************************************************************************************************/
/********** Partie 1: Constitution de la base d information datamining
***************************************/
/**********************************************************************************************************************/
/**********************************************************************************************************************/
/**********************************************************************************************************************/
/* a)Cration de la table pour alimentation au fur et mesure par jointures
successives */
/**********************************************************************************************************************/
%macro mpINITAB ;
data work.final ;
set Basestat.fre&m1.(in=b keep = matricul mtpfvers catben sitdos dtreffre
where = ( mtpfvers>0 and sitdos ne 'R' and catben ne "99" and &limit_test));
by matricul;
Call symputx("mvDTREFFRE", dtreffre) ;
run ;
%mend ;
%mpINITAB ;
/**********************************************************************************************************************/
/* b)Catgorie d'indicateurs : Historique FRE (ALLCAF) : (entrepts CAF
seulement) */
/* indus antrieurs + adresse + activit + abattement
et neutralisation */
/**********************************************************************************************************************/
/*MODIF DSER oct 2014 : rintgration variable SITFAM dans la macro HISTALCAF*/
%macro mpHISTALCAF ;
%do i= 1 %to 18 ;
data _null_ ; /* contrle existence des tables */
if (exist("Basestat.fre&&m&i.",'data') or exist("Basestat.fre&&m&i.",'view'))
then call symput ("topexist", "O") ;
else call symput ("topexist", "N") ;
run ;
%if &topexist. = O %then %do ;
Data work.ALLCAF&&m&i. ( drop = LILI4ADR LILI6ADR /**/ CATBEN);
merge work.final (in = a keep = MATRICUL )
Basestat.fre&&m&i. (in = b keep = MATRICUL SINDTOT SINDFNAL
SINDFNH SITFAM ACTCONJ ACTRESPD
LILI4ADR LILI6ADR /**/ CODEPOSD ABANEURE ABANEUCO MTLOYREM
CATBEN where = (CATBEN ne "99" ) );
by MATRICUL;
if a = 1 and b = 1;
rename
SINDTOT = SINDTOT&&m&i. SINDFNAL = SINDFNAL&&m&i.
SINDFNH = SINDFNH&&m&i. SITFAM =FAM&&m&i. ACTCONJ=ACJ&&m&i.
ACTRESPD= ACR&&m&i. CODEPOSD=POST&&m&i.
ABANEURE=ABNE&&m&i. ABANEUCO=ABNO&&m&i. MTLOYREM=MTLOYREM&&m&i.;
ADRESS&&m&i. = COMPBL(LILI4ADR!!" "!!LILI6ADR ) ; /*modif aot 2016*/
run ;
/* mise jour de la table final avec donnes existantes */
data work.final ;
merge work.final ( in = a )
work.ALLCAF&&m&i. ;
by matricul ;
if a = 1 ;
/*if (&mm.="06" and &aa.="10") then ADRESS_dernier=ADRESS&mm.&aa.;*/
run ;
/*Nettoyage de la work aprs jointure*/
proc datasets lib=work nolist; delete ALLCAF&&m&i. ; quit; run;
%end ;
%end ;
/*Cration des variables explicatives de la catgorie historique indus
antrieurs */
data work.final /*(drop=ADR: SINDTOT: SINDFNAL: SINDFNH:
FAM: ACJ: ACR: POST: ABNE: ABNO: )*/;
set work.final;
/*Vecteur des donnes historiques du plus rcents au plus anciens*/
array INDTOT %do i = 1 %to 18; SINDTOT&&m&i. %end ; ;
array INDFNAL %do i = 1 %to 18; SINDFNAL&&m&i. %end ; ;
array INDFNH %do i = 1 %to 18; SINDFNH&&m&i. %end ; ;
array ADR %do i = 1 %to 18; ADRESS&&m&i. %end ; ;
array fam %do i = 1 %to 18; fam&&m&i. %end ; ;
array post %do i = 1 %to 18; post&&m&i. %end ; ;
array actcon %do i = 1 %to 18; ACJ&&m&i. %end ; ;
array actresp %do i = 1 %to 18; ACR&&m&i. %end ; ;
array abno %do i = 1 %to 18; ABNO&&m&i. %end ; ;
array abne %do i = 1 %to 18; ABNE&&m&i. %end ; ;
array mtloy %do i = 1 %to 18; MTLOYREM&&m&i. %end ; ;
/*Initialisation des indicateurs*/
attrib INDTOT18 length=3. label="NB INDUS TOTAL SUR 18 MOIS";
attrib INDFNAL18 length=3. label="NB INDUS FNAL SUR 18 MOIS";
attrib INDFNH18 length=3. label="NB INDUS FNH SUR 18 MOIS";
attrib INDAL18 length=3. label="NB INDUS FNAL OU FNH SUR 18 MOIS";
attrib NADRESS18 length=3. label="NB CHGT ADRESSE 18 MOIS";
attrib MOIINDTOT length=3. label="NB MOIS DEPUIS DERNIER INDU";
attrib MOIINDFNPF length=3. label="NB MOIS DEPUIS DERNIER INDU FNPF";
attrib MOIINDFNAL length=3. label="NB MOIS DEPUIS DERNIER INDU AL";
attrib MOIINDFNH length=3. label="NB MOIS DEPUIS DERNIER INDU FNH";
attrib MOIINDAL length=3. label="NB MOIS DEPUIS DERNIER INDU FNH OU FNAL";
attrib MOIADRESS length=3. label="NB MOIS DEPUIS CHGT ADRESSE";
attrib MOIMODSIT length=3. label=
"NB MOIS DEPUIS UNE MODIFICATION DE SITUATION FAMILLE";
attrib NMODSIT12 length=3. label=
"NB MODIFICATIONS DE SITUATION FAMILLE SUR 12 MOIS";
attrib TOPSIT12 length=3. label=
"AU MOINS UNE MODIFICATION DE SITUATION FAMILLE SUR 12 MOIS";
attrib MOIMODACTR length=3. label=
"NB MOIS DEPUIS MODIF CODE ACTIVITE DU RESPDOS";
attrib MOIMODACTC length=3. label=
"NB MOIS DEPUIS MODIF CODE ACTIVITE DU CONJOINT";
attrib MOIMODACT length=3. label=
"NB MOIS DEPUIS MODIF CODE ACTIVITE DU RESPDOS OU DU CONJOINT";
attrib NMODACT12R length=3. label=
"NB DE MODIFICATION ACTIVIT SUR 12 MOIS (RESP)";
attrib NMODACT12C length=3. label=
"NB DE MODIFICATION ACTIVIT SUR 12 MOIS (CONJ)";
attrib NMODACT12 length=3. label=
"NB DE MODIFICATION ACTIVIT SUR 12 MOIS (RESP+CONJ)";
attrib MACT12R length=3. label="NB MOIS EN ACTIVIT SUR 12 MOIS (RESPDOS)";
attrib MACT12C length=3. label="NB MOIS EN ACTIVIT SUR 12 MOIS (CONJ)";
attrib MACT12 length=3. label=
"NB MOIS EN ACTIVIT SUR 12 MOIS (RESP et CONJ)";
attrib MOIMODNEUC length=3. label=
"NB MOIS DEPUIS MODIF CODE ABATTEMENT OU NEUTRAL (HORS AAH) DU CONJ";
attrib MOIMODNEU length=3. label=
"NB MOIS DEPUIS MODIF CODE ABATTEMENT OU NEUTRAL (HORS AAH) RESPDOS+CONJ";
attrib MODNEUR12 length=3. label=
"NB DE MODIF CODE AB OU NEUTRAL (HORS AAH) DU RESPDOS SUR 12 MOIS";
attrib MODNEUC12 length=3. label=
"NB DE MODIF CODE AB OU NEUTRAL (HORS AAH) DU CONJ SUR 12 MOIS";
attrib MODNEU12 length=3. label=
"NB DE MODIF CODE AB OU NEUTRAL (HORS AAH) DU RESPDOS OU DU CONJ SUR 12 MOIS";
attrib NMODAD12 length=3. label="NB MODIF CODEPOSTAL SUR 12 MOIS";
attrib TOPAD12 length=3. label="TOP MODIFICATION CODE POSTAL SUR 12 MOIS";
attrib NMODLOY6 length=3. label="TOP MODIFICATION CODE POSTAL SUR 6 MOIS";
attrib NMODLOY12 length=3. label="TOP MODIFICATION CODE POSTAL SUR 12 MOIS";
attrib NMODLOY18 length=3. label="TOP MODIFICATION CODE POSTAL SUR 18 MOIS";
/*Code de cration des indicateurs*/
INDTOT18=0; do i=1 to 18; if (INDTOT(i) ne . and INDTOT(i)>0) then do;
INDTOT18=INDTOT18+INDTOT(i); end;end;
INDFNAL18=0; do i=1 to 18; if (INDFNAL(i) ne . and INDFNAL(i)>0) then do;
INDFNAL18=INDFNAL18+INDFNAL(i); end;end;
INDFNH18=0; do i=1 to 18; if (INDFNH(i) ne . and INDFNH(i)>0) then do;
INDFNH18=INDFNH18+INDFNH(i); end;end;
INDAL18=INDFNH18+INDFNAL18;
NADRESS18=0;
ADRESS_dernier=adress&m1.;
do i=1 to 18;
if (ADR(i) ne " " and ADR(i) ne ADRESS_dernier) then do;
NADRESS18=NADRESS18+1;
ADRESDEP=ADR(i);
ADRESS_dernier=ADR(i); /*modif aot 2016 - correction adresse*/
end;
end;
MOIINDTOT=0; do i=1 to 18; if (INDTOT(i) ne . and INDTOT(i)>0) then do;
MOIINDTOT=i; i=18; end;end;
MOIINDFNPF=0; do i=1 to 18; if (INDFNPF(i) ne . and INDFNPF(i)>0) then do;
MOIINDFNPF=i; i=18; end;end;
MOIINDFNAL=0; do i=1 to 18; if (INDFNAL(i) ne . and INDFNAL(i)>0) then do;
MOIINDFNAL=i; i=18; end;end;
MOIINDFNH=0; do i=1 to 18; if (INDFNH(i) ne . and INDFNH(i)>0) then do;
MOIINDFNH=i; i=18; end;end;
MOIINDAL=0; do i=1 to 18; if ( (INDFNAL(i) ne . and INDFNAL(i)>0) or
(INDFNH(i) ne . and INDFNH(i)>0) ) then do; MOIINDAL=i; i=18; end;end;
MOIADRESS=0; ADRESS_dernier=adress&m1.;
do i=1 to 18;
if (ADR(i) ne " " and ADR(i) ne ADRESS_dernier) then do;
MOIADRESS=i;
i=18;
end;
end;
/*Situation familiale*/
MOIMODSIT=0; histosit=fam&m1.; do i=1 to 18; if fam(i) ne histosit and
fam(i) ne " " then do; MOIMODSIT=i-1; i=18; end;end;
histosit=fam&m1.; NMODSIT12=0; do i=1 to 12; if fam(i) ne histosit and
fam(i) ne " " then do; histosit=fam(i); NMODSIT12=NMODSIT12+1; end;end;
TOPSIT12=NMODSIT12>0;
/*loyers*/
/*MODIF DSER octobre 2014 : MTLOYREM&m1. au lieu de MTLOY&m1.*/
histoloy=mtloyrem&m1.; NMODloy6=0; do i=1 to 6; if mtloy(i) ne histoloy and
mtloy(i) ne " " then do; histoloy=mtloy(i); NMODLOY6=NMODLOY6+1; end;end;
histoloy=mtloyrem&m1.; NMODloy12=0; do i=1 to 12; if mtloy(i) ne histoloy and
mtloy(i) ne " " then do; histoloy=mtloy(i); NMODLOY12=NMODLOY12+1; end;end;
histoloy=mtloyrem&m1.; NMODloy18=0; do i=1 to 18; if mtloy(i) ne histoloy and
mtloy(i) ne " " then do; histoloy=mtloy(i); NMODLOY18=NMODLOY18+1; end;end;
/*Activit*/
histoactr=acr&m1.; do i=1 to 18; if ACTRESP(i) ne histoactr and actresp(i)
ne " " then do; MOIMODACTR=i-1; i=18; end;end;
histoactc=acj&m1.; do i=1 to 18; if ACTCON(i) ne histoactc and actcon(i) ne
" " then do; MOIMODACTC=i-1; i=18; end;end;
MOIMODACT=min(MOIMODACTC,MOIMODACTR); if MOIMODACT=. then MOIMODACT=0;
histoactr=acr&m1.; NMODACT12R=0; do i=1 to 12; if ACTRESP(i) ne histoactr
and actresp(i) ne " " then do; histoactr=ACTRESP(i); NMODACT12R=NMODACT12R+1;
end;end;
histoactc=acj&m1.; NMODACT12C=0; do i=1 to 12; if ACTCON(i) ne histoactc
and actcon(i) ne " " then do; histoactc=ACTCON(i); NMODACT12C=NMODACT12C+1;
end;end;
NMODACT12=sum(NMODACT12R, NMODACT12C);
MACT12R=0; do i=1 to 12;
if ACTRESP(i) in (/* Activit normale */'ACR', 'AMA', 'AMT', 'APP', 'CCV',
'CES', 'CIA', 'CIS', 'CGP', 'CSA', 'DNL', 'INT', 'MAL', 'MAT', 'MOA', 'PIL',
'SAL', 'SFP', 'TSA', 'VRP' ,'ETS',
/*Activit en milieu protg avec AAH */ 'AAP', 'CAT' , 'RAC',
/* entrepreneur, travailleur indpendant */'ETI', 'CJT', 'EXP', 'MAR',
'GSA' , 'EXS') then do; MACT12R=MACT12R+1; end;end;
MACT12C=0; do i=1 to 12;
if ACTCON(i) in (/* Activit normale */'ACR', 'AMA', 'AMT', 'APP', 'CCV',
'CES', 'CIA', 'CIS', 'CGP', 'CSA', 'DNL', 'INT', 'MAL', 'MAT', 'MOA', 'PIL',
'SAL', 'SFP', 'TSA', 'VRP' ,'ETS',
/*Activit en milieu protg avec AAH */ 'AAP', 'CAT' , 'RAC',
/* entrepreneur, travailleur indpendant */'ETI', 'CJT', 'EXP', 'MAR'
, 'GSA' , 'EXS') then do; MACT12C=MACT12C+1; end;end;
MACT12=MACT12R+MACT12C;
/*code postal*/
histoad=post&m1.; NMODAD12=0; do i=1 to 12; if post(i) ne histoad and
post(i) ne . then do; histoad=post(i); NMODAD12=NMODAD12+1; end;end;
topad12=nmodad12>0;
run;
%mend ;
%mpHISTALCAF ;
%macro mpFGHISTO ;
%do i= 1 %to 18 ;
data _null_ ; /* contrle existence des tables */
if (exist("basefrm.FAI&&m&i.",'data') or exist("basefrm.FAI&&m&i.",'view'))
then call symput ("topexist", "O") ;
else call symput ("topexist", "N") ;
run ;
%if &topexist. = O %then %do ;
data _null_ ; /* rcup de mois et de l'anne */
call symput("mvMOIS", substr("&&m&i.",1,2)) ;
call symput("mvANNEE", substr("&&m&i.",3,2)) ;
run ;
Data work.FAI&&m&i. ;
merge work.final (in = a keep = MATRICUL )
basefrm.FAI&&m&i. (in = b keep = MATRICUL DTSESLIQ FGELE ETATLIQ ETASSLIQ
ORILIQ RGMOUFG );
by MATRICUL;
if a = 1 and b = 1 ;
ATTRIB FORINET&&m&i. format = 8. informat = 8. length = 8 Label =
"NOMBRE DE FG D'ORIGINE INTERNET &&m&i." ;
ATTRIB FORIREC&&m&i. format = 8. informat = 8. length = 8 Label =
"NOMBRE DE FG D'ORIGINE PGME RECUP (CDASP) &&m&i." ;
if ETATLIQ in ("01" "03") and ETASSLIQ = "05"
and MDY(&mvMOIS.,01,&mvANNEE.) <= DTSESLIQ <= INTNX('MONTH',MDY(&mvMOIS.,01,&mvANNEE.),0, "end")
then do ;
FGTOT&&m&i. = 1 ;
if FGELE = "SITFAM" then SITFAM&&m&i = 1 ;
if FGELE = "RESANN" then RESANN&&m&i = 1 ;
if FGELE in ("RESTRIAPI" "RESTRIRMI" "RESTRIRSA" "RESTRIAAH" /*Modification PAC nov2015 - Ajout du Fg "Restrippa" */ "RESTRIPPA") then RESTR&&m&i = 1 ; /*Ajout fv.2014*/
if FGELE = "SITPRO" then SITPRO&&m&i = 1 ;
if ORILIQ in ("NET") then FORINET&&m&i. = 1 ;
if ORILIQ in ("REC") then FORIREC&&m&i. = 1 ;
end ;
/* INDICATEUR QUI NE SERVIRA QUE SUR LES 6 DERNIERS MOIS */
ATTRIB FGRESALL&&m&i. format = 8. informat = 8. length = 8 Label =
"NOMBRE DE FG RESANN D'ORIGINE ALLOCATAIRE &&m&i." ;
if FGELE = 'RESANN' and ETATLIQ in ("01" "03") and ETASSLIQ = "05" and
ORILIQ = "ALL" then FGRESALL&&m&i. = 1 ;
run ;
proc means data =work.FAI&&m&i. noprint nway ;
var SITFAM&&m&i. RESANN&&m&i. RESTR&&m&i. SITPRO&&m&i. FGRESALL&&m&i.
FORINET&&m&i. FORIREC&&m&i.;
class MATRICUL ;
output out = work.NBFG&&m&i. (drop = _type_ _freq_ ) sum() = ;
run ;
/* mise jour de la table final avec donnes existantes */
data work.final ;
merge work.final ( in = a )
work.NBFG&&m&i. ;
by matricul ;
if a = 1 ;
run ;
/*Nettoyage de la work aprs jointure*/
proc datasets lib=work nolist; delete NBFG&&m&i. ; quit; run;
proc datasets lib=work nolist; delete FAI&&m&i. temp; quit; run;
%end ;
%end ;
/*Cration des variables explicatives de la catgorie historique gestion
dossier */
data work.final (drop= i sitfam: fori: fgresall: sitpro: restr: resann: );
set work.final;
/*Vecteur des donnes historiques*/
array FAISANN %do i = 1 %to 18; RESANN&&m&i. %end ; ;
array FAIRESTR %do i = 1 %to 18; RESTR&&m&i. %end ; ;
array FAIPRO %do i = 1 %to 18; SITPRO&&m&i. %end ; ;
array FGRESALL %do i = 1 %to 18; FGRESALL&&m&i. %end ; ;
array FAIORINET %do i = 1 %to 18; FORINET&&m&i. %end ; ;
array FAIORIREC %do i = 1 %to 18; FORIREC&&m&i. %end ; ;
/*Initialisation des indicateurs*/
attrib FGORINET12 length=3. label="NB FG D'ORIGINE INTERNET SUR 12 MOIS";
attrib FGORIREC18 length=3. label="NB FG D'ORIGINE PGME RECUP (CDASP) SUR 18 MOIS";
attrib FGRESTRI18 length=3. label="NB FG RESTRI (HORS ANNULES) SUR 18 MOIS";
attrib MOIFGRESAN length=3. label="NB MOIS DEPUIS LE DERNIER FG RESANN (HORS ANNULES)";
/*Code de cration des indicateurs*/
FGORINET12=0; do i=1 to 12; if (FAIORINET(i) ne . and FAIORINET(i)>0) then do;
FGORINET12=FGORINET12+FAIORINET(i);
end;end;
FGORIREC18=0; do i=1 to 18; if (FAIORIREC(i) ne . and FAIORIREC(i)>0) then do;
FGORIREC18=FGORIREC18+FAIORIREC(i);
end;end;
FGRESTRI18=0; do i=1 to 18; if (FAIRESTR(i) ne . and FAIRESTR(i)>0) then do;
FGRESTRI18=FGRESTRI18+FAIRESTR(i);
end;end;
MOIFGRESAN=0; do i=1 to 18; if (FAISANN(i) ne . and FAISANN(i)>0) then do;
MOIFGRESAN=i; i=18;
end;end;
run;
%mend ;
%mpFGHISTO ;
/**********************************************************************************************************************/
/* d1)Catgorie d'indicateurs : Historique de contact (entrepts CAF seulement) */
/**********************************************************************************************************************/
%macro mp_HISTGCA ;
%do i= 1 %to 18 ;
data _null_ ; /* contrle existence des tables */
if (exist("gra.gca&&m&i.",'data') or exist("gra.gca&&m&i.",'view'))
then call symput ("topexist", "O") ;
else call symput ("topexist", "N") ;
run ;
%if &topexist. = O %then %do ;
proc sort data = GRA.GCA&&m&i. out = work.GCA&&m&i. ;
by matricul ;
run ;
Data work.gca&&m&i. ;
merge work.final (in = a keep = MATRICUL )
work.GCA&&m&i. (in = b keep = MATRICUL NATCONTA );
by MATRICUL;
if a = 1 and b = 1 ;
ATTRIB
VU&&m&i. format = 8. informat = 8. length = 8
LABEL = "NOMBRE DE CONTACTS PAR NATURE DE CONTACT ACCUEIL OU VISITE SUR &&m&i."
TEL&&m&i. format = 8. informat = 8. length = 8
LABEL = "NOMBRE DE CONTACTS PAR NATURE DE CONTACT TELEPHONE SUR &&m&i."
AUT&&m&i. format = 8. informat = 8. length = 8
LABEL = "NOMBRE DE CONTACTS PAR NATURE DE CONTACT AUTRES SUR &&m&i." ;
if natconta in ("A" "I" "N" "P" "V" ) then VU&&m&i. = 1 ;
if natconta in ("D" "R" ) then TEL&&m&i. = 1 ;
if natconta in ("B" "T" ) then AUT&&m&i. = 1 ;
run ;
proc means data = work.gca&&m&i. noprint nway;
VAR VU&&m&i. TEL&&m&i. AUT&&m&i. ;
class matricul ;
output out = work.CONTA&&m&i. (drop= _type_ _freq_) sum() = ;
run ;
/* mise jour de la table final avec donnes existantes */
data work.final ;
merge work.final ( in = a )
work.CONTA&&m&i. ;
by matricul ;
if a = 1 ;
run ;
%end ;
/*Nettoyage de la work aprs jointure*/
proc datasets lib=work nolist; delete GCA&&m&i. CONTA&&m&i.; quit; run;
%end ;
/*Cration des variables explicatives de la CATEGORIE DONNEES CONTACT */
data work.final (drop= VU: TEL: AUT: );
set work.final;
/*Vecteur des donnes historiques*/
array CONVU %do i = 1 %to 18; VU&&m&i. %end ; ;
array CONTEL %do i = 1 %to 18; TEL&&m&i. %end ; ;
array CONAUT %do i = 1 %to 18; AUT&&m&i. %end ; ;
/*Initialisation des indicateurs*/
attrib NBONTATEL18 length=3. label="NOMBRE DE CONTACT TEL EN 18 MOIS";
attrib NBONTAAUT18 length=3. label="NOMBRE DE CONTACT AUT EN 18 MOIS";
attrib MOIONTAVU length=3. label="NB MOIS DEPUIS CONTACT ACCUEIL";
attrib MOIONTATEL length=3. label="NB MOIS DEPUIS CONTACT TEL";
attrib MOIONTAAUT length=3. label="NB MOIS DEPUIS CONTACT AUT";
/*Code de cration des indicateurs*/
NBONTATEL18=0; do i=1 to 18; if (CONTEL(i) ne . and CONTEL(i)>0) then do;
NBONTATEL18=NBONTATEL18+CONTEL(i); end;end;
NBONTAAUT18=0; do i=1 to 18; if (CONAUT(i) ne . and CONAUT(i)>0) then do;
NBONTAAUT18=NBONTAAUT18+CONAUT(i); end;end;
MOIONTAVU=0; do i=1 to 18; if (CONVU(i) ne . and CONVU(i)>0) then do;
MOIONTAVU=i; i=18; end;end;
MOIONTATEL=0; do i=1 to 18; if (CONTEL(i) ne . and CONTEL(i)>0) then do;
MOIONTATEL=i; i=18; end;end;
MOIONTAAUT=0; do i=1 to 18; if (CONAUT(i) ne . and CONAUT(i)>0) then do;
MOIONTAAUT=i; i=18; end;end;
run;
%mend ;
%mp_HISTGCA ;
/**********************************************************************************************************************/
/* d2) Historique des connexions Web Caf.fr */
/**********************************************************************************************************************/
%macro mp_HISTWEB ; /*Modification octobre 2016 --> fusion donnes Web et bornes */
%do i= 1 %to 18 ;
data _null_ ; /* contrle existence des tables */
if (exist("gra.web&&m&i.",'data') or exist("gra.web&&m&i.",'view'))
then call symput ("topexist_web", "O") ;
else call symput ("topexist_web", "N") ;
run ;
data _null_ ; /* contrle existence des tables BIW*/
if (exist("gra.biw&&m&i.",'data') or exist("gra.biw&&m&i.",'view'))
then call symput ("topexist_biw", "O") ;
else call symput ("topexist_biw", "N") ;
run ;
%if &topexist_web. = O and &topexist_biw. = O %then %do ;
proc sort data = GRA.WEB&&m&i. out = work.WEB&&m&i. nodupkey;
by matricul dtcontwb;
run ;
proc sort data = GRA.BIW&&m&i. out = work.BIW&&m&i. nodupkey;
by matricul dtcontbo;
run ;
Data work.WEB&&m&i. ;
merge work.final (in = a keep = MATRICUL )
work.WEB&&m&i. (in = b keep = MATRICUL dtcontwb )
work.BIW&&m&i. (in = c keep = MATRICUL dtcontbo );
by MATRICUL;
if a = 1 and (b = 1 or c = 1) ;
ATTRIB
WEB&&m&i. format = 8. informat = 8. length = 8
LABEL = "NOMBRE DE CONNEXIONS (JOURS) WEB SUR &&m&i";
WEB&&m&i.=1;
/*if dtcontwb=. then dtcontwb=dtcontbo;*/
run ;
%end;
%if &topexist_web. = O and &topexist_biw.= N %then %do ;
proc sort data = GRA.WEB&&m&i. out = work.WEB&&m&i. nodupkey;
by matricul dtcontwb;
run ;
Data work.WEB&&m&i. ;
merge work.final (in = a keep = MATRICUL )
work.WEB&&m&i. (in = b keep = MATRICUL dtcontwb );
by MATRICUL;
if a = 1 and b = 1 ;
ATTRIB
WEB&&m&i. format = 8. informat = 8. length = 8
LABEL = "NOMBRE DE CONNEXIONS (JOURS) WEB SUR &&m&i";
WEB&&m&i.=1;
run ;
%end;
%if &topexist_web. = O %then %do ;
proc means data = work.WEB&&m&i. noprint nway;
VAR WEB&&m&i. ;
class matricul ;
output out = work.CONTWB&&m&i. (drop= _type_ _freq_) sum() = ;
run ;
/* mise jour de la table final avec donnes existantes */
data work.final ;
merge work.final ( in = a )
work.CONTWB&&m&i. ;
by matricul ;
if a = 1 ;
run ;
%end ;
/*Nettoyage de la work aprs jointure*/
proc datasets lib=work nolist; delete WEB&&m&i. CONTWB&&m&i. temp; quit; run;
%end ;
/*Cration des variables explicatives de la CATEGORIE DONNEES CONNEXIONS WEB
*/
data work.final (drop= WEB: );
set work.final;
/*Vecteur des donnes historiques*/
array CONWEB %do i = 1 %to 18; WEB&&m&i. %end ; ;
/*Initialisation des indicateurs*/
attrib NBCONWEB18 length=3. label="NOMBRE DE CONNEXIONS JOURNALIERES CAF.FR EN 18 MOIS";
/*Code de cration des indicateurs*/
NBCONWEB18=0; do i=1 to 18; if (CONWEB(i) ne . and CONWEB(i)>0) then do;
NBCONWEB18=NBCONWEB18+CONWEB(i); end;end;
run;
%mend ;
%mp_HISTWEB ;
/**********************************************************************************************************************/
/* e)Catgorie d'indicateurs : DIVERS SUR BASE INFOCENTRE (entrepts CAF
seulement) */
/**********************************************************************************************************************/
/*DONNEES DOS **/
Data work.final ;
merge work.final ( in = a)
basefrm.DOS ( in = b keep = MATRICUL MODPAIDO DTINSCDO TITUREDO TITUPRDO)
;
by matricul ;
if a = 1 and b = 1 ;
rename MODPAIDO = MODPAIDO_dernier
DTINSCDO = DTINSCDO_dernier
TITUREDO = TITUREDO_dernier
TITUPRDO = TITUPRDO_dernier ;
run ;
/*Nettoyage de la work aprs jointure*/
proc datasets lib=work nolist; delete DOS ;
quit; run;
/**************************************************************************************************/
/* f)Catgorie d'indicateurs : HISTORIQUE SITUATION CONTROLE ET VERIFICATION */
/**************************************************************************************************/
%macro mp_CTRLVERIF ;
%do i= 1 %to 18 ;
/*FVAP*//*Recup donnes verif comptable apr*/
data _null_ ; /* contrle existence des tables */
if (exist("basestat.fvap&&m&i.",'data') or exist("basestat.fvap&&m&i.",'view'))
then call symput ("topexist", "O") ;
else call symput ("topexist", "N") ;
run ;
%if &topexist. = O %then %do ;
data work.fvap&&m&i. ;
merge work.final (in = a keep = MATRICUL )
Basestat.fre&&m&i. (in = b keep = MATRICUL CATBEN where = (CATBEN ne "99" ))
basestat.fvap&&m&i. (in = c keep = MATRICUL CIBVERAP MTFVERAP );
by MATRICUL;
if a = 1 and b = 1 and c = 1 ;
rename
CIBVERAP=CIBV&&m&i. ;
if first.matricul ;
run ;
/*proc sort data = work.fvap&&m&i. nodupkey ; by matricul ; run ; */
data work.final ;
merge work.final ( in = a )
work.fvap&&m&i. ;
by matricul;
if a = 1 ;
run ;
%end ;
/*Nettoyage de la work aprs jointure*/
proc datasets lib=work nolist; delete fvap&&m&i.; quit; run;
%end ;
/*Cration des variables explicatives de la CATEGORIE HISTORIQUE SITUATION
DOSSIER ALLNAT */
data work.final (drop= CIBV: );
set work.final;
/*Vecteur des donnes historiques*/
array cibv %do i = 1 %to 18; CIBV&&m&i.%end ; ;
/*Initialisation des indicateurs*/
attrib MOICONTVER length=3. label="NB MOIS DEPUIS DERNIER CONTRLE VERIF";
/*Cration d'une dure depuis un contrle caf vrif*/
do i=1 to 18; if cibv(i) >'0' then do; MOICONTVER=i; i=18; end;end;
run;
%mend ;
%mp_CTRLVERIF ;
/**********************************************************************************************************************/
/* h)Catgorie d'indicateurs : DONNEES SDP */
/**********************************************************************************************************************/
proc sort data=gra.sdsuiarr out=SDP; by matricul; run;
Data SDP ;
merge SDP (in = a keep = MATRICUL DTARRPIE ETATSDP IDNATPIE TYCREASD NATPIE RGCREASD
where=(rgcreasd=1 and tycreasd in ("3" "5" "8" "6")))
work.final (in = b keep = MATRICUL );
by MATRICUL;
if a = 1 and b = 1 ;
dtarrpie_mmaa=compress(put(month(dtarrpie),z2.)!!SUBSTR(put(year(dtarrpie),z4.),3,2)) ;
run;
%macro mp_comptesdp(mv_table,mv_natpie,mv_tabsortie,mv_libvar);
proc means data = &mv_table noprint;
VAR matricul ;
where (dtarrpie_mmaa="&&m&i." and &mv_natpie.);
output out = &mv_tabsortie. (drop= _type_ _freq_) N = &mv_libvar.;
class matricul;
run ;
%mend;
%macro mp_SDP() ;
%do i= 1 %to 18 ;
%mp_comptesdp(SDP, (tycreasd eq "6" And NATPIE eq "MELALL"),work.PIE_MAIL&&m&i., PIE_MAIL&&m&i..);
%mp_comptesdp(SDP, (tycreasd in ("3" "5" "8") And NATPIE IN ("NPAI","PND")), work.PIE_NPAI&&m&i., PIE_NPAI&&m&i..);/*MODIF DU 28/11/2016 - NPAI a t remplac par PND*/
%mp_comptesdp(SDP, (NATPIE eq "DSIT"), work.PIE_DSIT&&m&i., PIE_DSIT&&m&i..);
%mp_comptesdp(SDP, (NATPIE eq "NOTINT"),work.PIE_NOTINT&&m&i., PIE_NOTINT&&m&i..);
%mp_comptesdp(SDP, (NATPIE eq "DSFAM"),work.PIE_DSFA&&m&i., PIE_DSFA&&m&i..);
/* mise jour de la table final avec donnes existantes */
data work.final ;
merge work.final ( in = a )
work.PIE_MAIL&&m&i.
work.PIE_NPAI&&m&i. work.PIE_DSIT&&m&i.
work.PIE_NOTINT&&m&i. work.PIE_DSFA&&m&i. ;
by matricul ;
if a = 1 ;
run ;
/*Nettoyage de la work aprs jointure*/
proc datasets lib=work nolist;
delete PIE_TELE&&m&i. PIE_MAIL&&m&i.
PIE_NPAI&&m&i. PIE_DSIT&&m&i.
PIE_NOTINT&&m&i. PIE_DSFA&&m&i.;
quit; run;
%end;
/*Cration des variables explicatives de la CATEGORIE DONNEES SDP */
data work.final (drop= PIE: COU:);
set work.final;
/*Vecteur des donnes historiques*/
array PIE_MAIL %do i = 1 %to 18; PIE_MAIL&&m&i.. %end ;;
array PIE_NPAI %do i = 1 %to 18; PIE_NPAI&&m&i.. %end ;;
array PIE_DSIT %do i = 1 %to 18; PIE_DSIT&&m&i.. %end ;;
array PIE_NOTINT %do i = 1 %to 18; PIE_NOTINT&&m&i.. %end ;;
array PIE_DSFA %do i = 1 %to 18; PIE_DSFA&&m&i.. %end ;;
/*Initialisation des indicateurs*/
attrib NBPIE_DSIT18 length=3. label="NOMBRE DE PIECES DSIT 18 MOIS";
attrib NBPIE_MAIL18 length=3. label="NOMBRE DE MAILS 18 MOIS";
attrib MOIPIE_NOTINT length=3. label="NB MOIS DEPUIS DEBUT NOTE INTERNE";
attrib MOIPIE_NPAI length=3. label="NB MOIS DEPUIS DEBUT NPAI";
attrib MOIPIE_DSIT length=3. label="NB MOIS DEPUIS DEBUT DSIT";
attrib MOIPIE_MAIL length=3. label="NB MOIS DEPUIS DEBUT MAIL";
/*Code de cration des indicateurs*/
NBPIE_MAIL18=0; do i=1 to 18; if (PIE_MAIL(i) ne . and PIE_MAIL(i)>0) then do;
NBPIE_MAIL18=sum(NBPIE_MAIL18,PIE_MAIL(i)); end;end;
NBPIE_DSIT18=0; do i=1 to 18; if (PIE_DSIT(i) ne . and PIE_DSIT(i)>0) then do;
NBPIE_DSIT18=sum(NBPIE_DSIT18,PIE_DSIT(i)); end;end;
attrib MOIPIE_MAIL length=3. label="NB MOIS DEPUIS PIECE MAIL";
attrib MOIPIE_NPAI length=3. label="NB MOIS DEPUIS PIECE MNPAI";
attrib MOIPIE_DSIT length=3. label="NB MOIS DEPUIS PIECE MDSIT";
attrib MOIPIE_DSFA length=3. label="NB MOIS DEPUIS PIECE MDSITFAM";
attrib MOIPIE_NOTINT length=3. label="NB MOIS DEPUIS PIECE NOTE INT.";
MOIPIE_MAIL=0; do i=1 to 18; if (PIE_MAIL(i) ne . and PIE_MAIL(i)>0) then do;
MOIPIE_MAIL=i; i=18; end;end;
MOIPIE_NPAI=0; do i=1 to 18; if (PIE_NPAI(i) ne . and PIE_NPAI(i)>0) then do;
MOIPIE_NPAI=i; i=18; end;end;
MOIPIE_DSIT=0; do i=1 to 18; if (PIE_DSIT(i) ne . and PIE_DSIT(i)>0) then do;
MOIPIE_DSIT=i; i=18; end;end;
MOIPIE_DSFA=0; do i=1 to 18; if (PIE_DSFA(i) ne . and PIE_DSFA(i)>0) then do;
MOIPIE_DSFA=i; i=18; end;end;
MOIPIE_NOTINT=0; do i=1 to 18; if (PIE_NOTINT(i) ne . and PIE_NOTINT(i)>0) then do;
MOIPIE_NOTINT=i; i=18; end;end;
run;
%mend;
%mp_SDP() ;
/************************************************************************************/
/* i)Catgorie d'indicateurs : SITUATION DOSSIER FRE SUR LA DATE DE REFERENCE */
/************************************************************************************/
data work.final ;
merge work.final ( in = a )
Basestat.fre&m1. ( keep= CATBEN AAHVERS AAHPERE ABANEUCO ABANEURE ACTCONJ ACTRESPD
ALFVERS ALSVERS APLVERS ANNNEN1-ANNNEN12 MOINEN1-MOINEN12 QUALEN1-QUALEN12
ASFVERS COMPLAAH DTNAICON DTNAIRES DTREFFRE MATRICUL
MTLOGCAL MTLOYREM MTPAJCAV MTPFVERS MTREMRSV MTREVBRU NAUTLOGV
NBENFCHA NBENLEFA NBNAIMOI NECHALOG NORDALLC NUMCAF PAJEVERS PERSCOUV PPRPPU
PRESCONJ RESALTDO RESTRACE RESTRACO revactmo revactme RESTRAC2 RSASOCL RSAVERS RSDTDORI
SEXE SITFAM TIEPAALI NATTUT STATUETU
/*MODIF DSER oct 2014 : variables revactmo revactme restrac2 n'taient pas dans le KEEP*/
/*Modification PAC nov2015 : ajout des nouvelles variables et suppression des anciennes */
%if (&mv_pres_RSAACT. gt 0) %then %do; RSAACT %end;
%if (&mv_pres_RESTRRSA. gt 0) %then %do; RESTRRSA %end;
%if (&mv_pres_MTOTFOY. gt 0) %then %do; MTOTFOY1 MTOTFOY2 MTOTFOY3 %end;
%if (&mv_pres_DTINCOAC. gt 0) %then %do; DTINCOAC %end;
%if (&mv_pres_PPAVERS. gt 0) %then %do; PPAVERS %end;
where = (catben ne "99"));
by matricul ;
if a = 1 ;
if first.matricul ;
run;
/**********************************************************************************************************************/
/**********************************************************************************************************************/
/********** Partie 2 : Recodages et crations de nouvelles variables **************************************/
/**********************************************************************************************************************/
/**********************************************************************************************************************/
/* FORMATS DATAMINING*/
proc format;
picture sepmil low-<0='000 000 000 009' (prefix='-') 0-high='000 000 000 009' (prefix=' ');
picture sepmild low-<0='000 000 000 009,0' (decsep=',' prefix='-') 0-high='000 000 000 009,0' (decsep=',' prefix=' ');
value $_act
/* Cong mater*/ "MAT","CSS","CAC","SAB","CCV"="CON"
/* Activit normale */"ACR", "AMA", "AMT", "APP", "CES", "CIA", "CIS", "CGP", "CSA", "DNL", "INT", "MOA", "PIL", "SAL", "SFP", "TSA", "VRP" ,"ETS",
/*Activit en milieu protg avec AAH */ "AAP", "CAT" , "RAC"="ACT"
/* entrepreneur, travailleur indpendant */"ETI", "CJT", "EXP", "MAR", "GSA" , "EXS"="ETI"
/* Chmage*/ "CAR" ,"CHO","ABA", "AFC", "ADA", "CDA", "CPL", "FDA", "MMC" ,"ASP","ASS", "AFD", "AIN", "ADN", "CDN", "CNI", "ANI", "FDN" , "MMI"="CHO"
/* Retraite*/ "RET"="RET"
/*ETUDIANT*/ "EBO" , "ETU" = "ETU"
/*INACTIFetinconnu*/ "SSA", "AFA", "MOC", "SNR", "SAV", "SIN", "MAL"="INA"
"00","000","99"="0CO"
"XXX"="XXX"
/*AUTRES*/ other="AUT";
value $_actr /*AJOUT D'UN CODAGE SPECIFIQUE PR L'ACTIVITE DU CONJOINT*/
/* Cong mater*/ "MAT","CSS","CAC","SAB","CCV"="CON"
/* Activit normale */"ACR", "AMA", "AMT", "APP", "CES", "CIA", "CIS", "CGP", "CSA", "DNL", "INT", "MOA", "PIL", "SAL", "SFP", "TSA", "VRP" ,"ETS",
/*Activit en milieu protg avec AAH */ "AAP", "CAT" , "RAC"="ACT"
/* entrepreneur, travailleur indpendant */"ETI", "CJT", "EXP", "MAR", "GSA" , "EXS"="ETI"
/* Chmage*/ "CAR" ,"CHO","ABA", "AFC", "ADA", "CDA", "CPL", "FDA", "MMC" ,"ASP","ASS", "AFD", "AIN", "ADN", "CDN", "CNI", "ANI", "FDN" , "MMI"="CHO"
/* Retraite*/ "RET"="RET"
/*ETUDIANT*/ "EBO" , "ETU" = "ETU"
/*INACTIFetinconnu*/ "SSA", "AFA", "MOC", "SNR", "SAV", "SIN", "MAL"="INA"
"XXX"="XXX"
/*AUTRES*/ other="AUT";
value MTLOGC_F(fuzz=0.005 ) 0-<1='0' 1-<150 ='de 1 150' 150 -< 300 ='de 150 300' 300-high ='suprieur 300';
value MTPAJCAV_quant
0="0"
0.001-<361="0 361"
361-high="361 et+"
.="MISSAUT"
other="MISSAUT" ;
value agecon_quant
60-high="60 et plus"
.="MISSAUT"
other="MISSAUT";
value ageresp_quant
0-<34="00 33"
other="MISSAUT";
value $OCLOG_P "20", "21", "22", "23", "24", "40", "41", "80", "81", "82",
"83", "84","70", "71", "72", "73", "74", "75", "76" ="ACCESSION"
other="AUTRE";
value DTINSCDO_dernier_quant
0-<12936="0 <12936"
12936-<14302="12936 <14302"
14302-<15941="14302 <15941"
15941-<17976="15941 <17976"
17976-19417 ="17976 <=19417"
.="MISSAUT"
other="MISSAUT";
value NBM_ODMS_quant
0-<1="0 <1"
1-<13="1 <13"
13-<32="13 <32"
32-500="32 500"
/*60-291 ="60 <=291"*/
.="MISSAUT"
other="MISSAUT";
value TXEFF_P(fuzz=1.110223E-16 )
-100000 - <35='0aLettxeff 0a35'
35-high='35etplus';
value NBWEB18_quant
0-<4="0 <4"
/*1-<4="1 <4"*/
4-<12="4 <12"
12-<34="12 <34"
34-high ="34 <=504"
.="MISSAUT"
other="MISSAUT";
value RUC_RED_quant
/*0-<0.16="0 <0.16"*/
0-<577="0 <577"
577-<942="577 <942"
942-<1483.33="942 <1483.33"
1483.33-high ="1483.33 <=19745" /*Modification nov2015 pour tenir compte des RUC >19745 */
.="MISSAUT"
other="MISSAUT";
value MOINSCDO_quant
0-<12="0 <12"
12-<49="12 <49"
49-high ="49 et plus"
.="MISSAUT"
other="MISSAUT";
value MTPFUC_F(fuzz=1.776357E-15 )
0-<213.69591859 ='de 1 213.7 '
213.69591859 -< 454.43788174 ='de 213.7 454.4 '
454.43788174 -< 695.17984489 ='de 454.4 695.2 '
695.17984489 -high ='suprieur 695.2 ';
value $prescj
'0'=" SANS_CONJOINT"
'2'="AV_CONJOINT";
run;
/********************************************************************************/
/* ETAPES DE CREATION DES VARIABLES A PARTIR DES DONNES BRUTES */
/********************************************************************************/
data work.Final ;
set work.Final;
/*********************************************************************************/
/*0- Maintenance des modles: Modification de variables suite volution du DII */
/*********************************************************************************/
/*Modification PAC nov2015 : Remplacement de RSDTDORI par DTINCOAC*/
%if (&mv_pres_DTINCOAC. eq 0) %then %do; if RSDTDORI>0 then NBM_ODMS=INTCK("MONTH",RSDTDORI,dtreffre); else NBM_ODMS=0; %end;
%if (&mv_pres_DTINCOAC. gt 0) %then %do; if DTINCOAC>0 then NBM_ODMS=max(0,INTCK("MONTH",DTINCOAC,dtreffre)); else NBM_ODMS=0; %end; /*Corr juin 2016*/
label NBM_ODMS= "NB MOIS DEPUIS OD MS (API ou RMI)";
/************************************************************************/
/*1- Gestion des donnes manquantes - Recodage direct de variables */
/************************************************************************/
/*GESTION DES REVENUS INCONNUS*/
if MTREVBRU=. then mtrevbru=999999;
if MTLOYREM>9000 then mtloyrem=9999;
/*DATE NAISSANCE INCONNUE*/
if dtnaires=. then dtnaires=mdy(1,1,1970);
/************************************************************/
/*2- CREATION DE VARIABLES DIRECTEMENT SUR DONNEES SOURCES */
/************************************************************/
if aahvers>'0' or complaah>'0' then AAH_COMPAAH="AAH"; else AAH_COMPAAH="0";
label AAH_COMPAAH= "DROIT AAH";
if aahvers>'0' or complaah>'0' then AAH_COMPAAH_P="AAH"; else AAH_COMPAAH_P="0";
label AAH_COMPAAH_P="TOP AAH OU COMPLEMENT";
/*Abattement ou neutral*/
if (abaneure>0 or abaneuco>0) then ABANEU="Ab. ou neutral."; else ABANEU="Aucun";
label ABANEU= "TOP ABATTEMENT OU NEUTRAL POUR ALLOC OU CONJOINT";
ACTCONJ_f=put(ACTCONJ,$_act.);
label ACTCONJ_f= "ACTIVIT CONJOINT";
ACTRESPD_f=put(ACTRESPD,$_actr.);
label ACTRESPD_f= "ACTIVIT RESP DOS.";
if dtnaicon ne . then agecon=round ( INTCK("MONTH",dtnaicon,dtreffre) /12 );
label agecon= "AGE CONJOINT";
if dtnaires ne . then ageresp=round ( INTCK("MONTH",dtnaires,dtreffre) /12 );
label ageresp= "AGE RESP. DOS";
agecon_quant=put(agecon,agecon_quant.); label agecon_quant="AGE CONJOINT";
ageresp_quant=put(ageresp,ageresp_quant.); label ageresp_quant="AGE RESP. DOS";
if ASFVERS>'0' then ASF="ASF";else ASF="0";
label ASF= "DROIT ASF";
if ((ALFVERS>'0') or (ALSVERS>'0') or (APLVERS>'0')) then AL="AL"; else AL="0";
label AL= "DROIT AUX AL";
MTLOGCAL_f= put(MTLOGCAL,MTLOGC_f.);
label MTLOGCAL_f= "MONTANT D AIDE AU LOGEMENT VERSABLE";
attrib Nbenf02 label="NB ENFANTS DE 0 A 2 ANS REVOLUS" format=1. informat=1.;
attrib Nbenf35 label="NB ENFANTS DE 3 A 5 ANS REVOLUS" format=1. informat=1.;
attrib Nbenf611 label="NB ENFANTS DE 6 A 11 ANS REVOLUS" format=1. informat=1.;
attrib Nbenf1218 label="NB ENFANTS DE 12 A 18 ANS REVOLUS" format=1. informat=1.;
attrib Nbenf18p label="NB ENFANTS DE PLUS DE 18 ANS REVOLUS" format=1. informat=1.;
label TOPEN19= "Top enfant >19 ans";
attrib datenai label="DATENAI TEMP" format=yymmdd10.;
array mois[12] moinen1-moinen12;
array annee[12] annnen1-annnen12;
Nbenf02=0; Nbenf35=0; Nbenf611=0; Nbenf1218=0; Nbenf18p=0;TOPEN19=0;
do i=1 to min(nbenlefa,12);
if annee[i] in (0,.) then datenai=.;
else do;
if mois[i] in (0,.) then mois[i]=6;
datenai=mdy(mois[i],1,annee[i]);
age=int(datdif(datenai,dtreffre,'ACT/ACT')/365);
end;
if (age < 3) then Nbenf02=Nbenf02+1;
if (age >= 3 and age < 6) then Nbenf35=Nbenf35+1;
if (age >= 6 and age < 11) then Nbenf611=Nbenf611+1;
if (age >= 12 and age < 18) then Nbenf1218=Nbenf1218+1;
if (age >= 18) then Nbenf18p=Nbenf18p+1;
if (age >= 19) then TOPEN19=1;
end;
Nbenf02=sum(Nbenf02,nbnaimoi);
if nbenf02 > 0 then TOPENF02='1'; else TOPENF02='0';
if nbenf02 > 0 then TOPENF02_P='1'; else TOPENF02_P='0';
label TOPENF02_P="TOP PRESENCE ENFANT DE 0 A 2 ANS";
if nbenf1218 > 0 then TOPENF1218='1'; else TOPENF1218='0';
if nbenf1218 > 0 then TOPENF1218_P='1'; else TOPENF1218_P='0';
label TOPENF1218_P="TOP PRESENCE ENFANT DE 12 A 18 ANS";
presconj_f=put(presconj,$prescj.);
label presconj_f= "SITUATION FAMILIALE";
if (RSAVERS ne '0' /*Modification PAC nov2015 : ajout PPA */ %if (&mv_pres_PPAVERS. gt 0) %then %do; or PPAVERS ne "0" %end; )
then MS="MS (+ARE)"; else MS="0";
label MS= "DROIT UN MINIMUM SOCIAL ou RSA Activit/PPA";
NBUC=0;
array tab{12} annnen1 annnen2 annnen3 annnen4 annnen5 annnen6 annnen7 annnen8 annnen9 annnen10 annnen11 annnen12;
n13=nbnaimoi;n14=0;n611=0;n1214=0;n1518=0;
do i=1 to 12;
select(tab{i});
when (0);
otherwise do;
if year(dtreffre)-tab{i} <= 13 then n13=n13+1;
if year(dtreffre)-tab{i} >13 then n14=n14+1;
end;end;end;
If (PRESCONJ='0') then do;
If (n13+n14=0) then NBUC=1.0;
else NBUC=1.2 +(0.3*n13) +(0.5*(n14));
end;
else NBUC=1.0 +(0.3*n13) +(0.5 * (1+ n14));
label NBUC="NB UNITE CONSOMMATION";
MTPAJCAV_quant=put(MTPAJCAV,MTPAJCAV_quant.);
label MTPAJCAV_quant="MONTANT PAJE COMPLEMENT ACTIVITE VERSABLE";
if (pajevers>'0' ) then PAJE_AFEAGED="PAJE";else PAJE_AFEAGED="0";
label PAJE_AFEAGED= "DROIT PAJE";
/* Calcul des revenus mensuels hors PF*/
/* suppression Donnes RMI et API : RESTRAPI RESTRRMI*/
/*Maintenance : Ajout code pour RESTRRSA*/
/*Modification PAC nov2015 : remplacement de RESTRRSA par MTOTFOY1-2-3 */
if (RSAVERS ne '0' %if (&mv_pres_PPAVERS. gt 0) %then %do; or PPAVERS ne "0" %end;)
then do;
%if (&mv_pres_mtotfoy. gt 0) %then %do;
if sum(mtotfoy1,mtotfoy2,mtotfoy3)<=9000 then revmens=sum(mtotfoy1,mtotfoy2,mtotfoy3);
else if sum(mtotfoy1,mtotfoy2,mtotfoy3)>9000 then revmens=99999;
%end;
%if (&mv_pres_mtotfoy. eq 0) %then %do;
if restrrsa<=9000 then revmens=max(RESTRRSA,MTREMRSV*3)/3;
else if restrrsa>9000 then revmens=99999;
%end;
end;
else if mtrevbru>900000 then REVMENS = 99999;
else revmens=round(mtrevbru/12);
label REVMENS= "REVENUS MENSUALISES TRIM OU AN2";
if NATTUT > '0' then tut_P="TUTELLE"; else tut_P="0";
label tut_P="TOP TUTELLE";
/*************************************************************************************************************/
/*3- CREATION DE VARIABLES RECOMBINEES ( partir de variables cres en 1) - classes par ordre alphabtique)*/
/*************************************************************************************************************/
if DTINSCDO_dernier=. then MOINSCDO=0; else MOINSCDO=intck("MONTH",DTINSCDO_dernier,DTREFFRE);
If MOINSCDO=-1 then MOINSCDO=0; /* Modification nov.2015 pour prise en compte de la valeur -1*/
label MOINSCDO="NB MOIS DEPUIS AFFILIATION PAR RAPPORT dernier mois";
MOINSCDO_quant=put(MOINSCDO,MOINSCDO_quant.);
label MOINSCDO_quant="NB MOIS DEPUIS AFFILIATION PAR RAPPORT dernier mois";
/*Montant de prestation par UC*/
mtprest=sum(mtpfvers); if mtprest=. then mtprest=0;
label MTPREST="MONTANT DE PRESTATION PERCUE";
mtprestuc=mtprest/nbuc;
label MTPRESTUC="Montant de prestation vere par UC";
mtprestuc_f=put(mtprestuc,mtpfuc_f.);
label MTPRESTUC_f="Montant de prestation vere par UC";
/*Anciennet en classes*/
NBM_ODMS_quant=put(NBM_ODMS,NBM_ODMS_quant.);
label NBM_ODMS_quant="NB MOIS DEPUIS OD MS (API ou RMI)";
/*************************************************************************************************/
/*4- Redressement des donnes manquantes et cration de variables partir des donnes redresses */
/*************************************************************************************************/
/*Redressement de la variable revmens et cration de variables*/
TOP_1conj0ms0al =((PRESCONJ_f="AV_CONJOINT") and (MS="0") and (AL="0") );
TOP_1conj0ms1al=( (PRESCONJ_f="AV_CONJOINT") and (MS="0") and (AL="AL") );
TOP_1conj1ms0al =( (PRESCONJ_f="AV_CONJOINT") and (MS="MS (+ARE)") and (AL="0") );
TOP_1conj1ms1al =( (PRESCONJ_f="AV_CONJOINT") and (MS="MS (+ARE)") and (AL="AL") );
TOP_0conj0ms0al =((PRESCONJ_f="SANS_CONJOINT") and (MS="0") and (AL="0"));
TOP_0conj0ms1al =((PRESCONJ_f="SANS_CONJOINT") and (MS="0") and (AL="AL"));
TOP_0conj1ms0al=((PRESCONJ_f="SANS_CONJOINT") and (MS="MS (+ARE)") and (AL="0") );
TOP_0conj1ms1al=((PRESCONJ_f="SANS_CONJOINT") and (MS="MS (+ARE)") and (AL="AL") );
toppaje=(PAJE_AFEAGED="PAJE");
topasf=(ASF="ASF");
topaah=(AAH_COMPAAH="AAH");
femme=(SEXE="2");
activresp=(ACTRESPD_f="ACT");
activconj=(ACTCONJ_f="ACT");
chomage=((ACTRESPD_f="CHO") or (ACTCONJ_f="CHO"));
/* Modle de redressement de la variable revmens */
/* sur 9290 observations : revmens connus et mtprest> *//* R=0,622783 dl=17 */
if REVMENS=99999 then do;
REVMENS_RED=max(0,189.972886 + activconj * (679.110808 ) + activresp * (449.804327 ) + ageresp * (9.074702 ) + chomage * (214.096473 ) + femme * (82.879216 ) +
mtprest * (-0.50641 ) + NBENFCHA * (182.126509 ) + TOP_0conj0ms0al * (-127.991336 ) +
TOP_0conj0ms1al * (-253.894658 ) + TOP_0conj1ms0al * (-577.076753 ) + TOP_0conj1ms1al * (-482.715358 ) + TOP_1conj0ms0al * (1317.410976 ) +
TOP_1conj1ms0al * (-684.857514 ) + TOP_1conj1ms1al * (-536.331104 ) + topaah * (-183.599325 ) + topasf * (-124.570829 ) + toppaje * (266.586659 ));
end;
else REVMENS_RED=REVMENS;
label revmens_red="REVENUS MENSUALISES (yc PF, priorit DTR sur ANNUELS) REDRESSES";
if (MS="MS (+ARE)") then restri_red=revmens_red; else restri_red=99999;
if (MS="MS (+ARE)") then restriuc_red=revmens_red/nbuc; else restriuc_red=99999;
RUC_RED=REVMENS_RED/NBUC; label RUC_RED="RUC Mensuel hors PF";
RUC_RED_quant=put(RUC_RED,RUC_RED_quant.);
label RUC_RED_quant="RUC Mensuel hors PF";
/*Redressement de la variable MTREVBRU et cration de variables*/
/*Modle de redressement de la variable mtrevbru*/
/*sur 9166 observations : mtrevbru connus *//*R=0,595 dl=17 */
if MTREVBRU>=9999998 then do;
MTREVBRU_RED=max(0,1380.700333 + NBENFCHA * (1836.558261 ) + ageresp * (109.650043 ) + mtprest * (-4.632265 ) +
TOP_1conj0ms0al * (16291.540008 ) + TOP_1conj1ms0al * (-6522.248891 ) + TOP_1conj1ms1al * (-4408.085236 ) +
TOP_0conj0ms1al * (-2569.735729 ) + TOP_0conj1ms0al * (-5630.168175 ) + TOP_0conj1ms1al * (-4575.663174 ) +
chomage * (3652.423686 ) + toppaje * (3042.850353 ) + topasf * (-1836.292169 ) + topaah * (-3369.087472 ) +
femme * (773.741889 ) + activresp * (5482.94001 ) + activconj * (8673.047286 ));
end;
else MTREVBRU_RED=MTREVBRU;
label mtrevbru_red="REVENUS ANNUELS N-2 BRUTS REDRESSES";
/*Taux d'effort logement sur revenus mensualiss redresss*/
if mtlogcal>0 then do;
charge=49.14+ 11.12*(nechalog+nautlogv);
loyer=sum(charge,mtloyrem);
if mtloyrem=9999 then txeff=-1;
else if (revmens_red/*+mtprest-mtlogcal*/)=0 then txeff=-1;
else txeff=((loyer-mtlogcal)/(revmens_red/*+mtprest-mtlogcal*/))*100;
restaviv=max(0,revmens_red+mtprest-loyer);
end;
else do; txeff=-2; restaviv=-2; loyer=0; charge=0; end;
label TXEFF="TAUX EFFORT LOGEMENT APRES AIDE";
label restaviv="RESTE A VIVRE APRES PAIEMENT DU LOYER ET VERSEMENT AIDE LOGEMENT";
TXEFF_P=put(txeff,TXEFF_P.);
label TXEFF_P="TAUX D EFFORT LOGEMENT APRES AIDE";
/*************************************************************************/
/** 5- Cration de nouveaux indicateurs **/
/*************************************************************************/
if statuetu in ("1" "2") then statuetu ="1";
else if statuetu in ("3" "4") then statuetu ="3";
/*AAHINTA*/
attrib TYPAAH length=$1. label="AAH TRIM ou ANNUEL ";
if AAHPERE='2' and AAHVERS ne '0' then TYPAAH='1'; else
if AAHVERS ne '0' then TYPAAH='2';else TYPAAH='0';
/*Cration de nouveaux indicateurs*/
/*Top revenus inconnus*/
attrib TOPREVINCAN length=$1. label="TOP REV AN REF INCONNUS ";
attrib TOPREVINCTRIM length=$1. label="TOP REV DTR M-2 INCONNUS ";
if mtrevbru>999998 then TOPREVINCAN='1';else TOPREVINCAN='0';
if restrac2>9998 then TOPREVINCTRIM='1';else TOPREVINCTRIM='0';
/*Titulaire compte versement & prelvt*/
attrib TITUBANC length=$1. label="COMPAR RIB";
TITUBANC='1';
if TITUREDO_dernier ne "" then do;
if sexe="1" and (index(TITUREDO_dernier,"O")=0) then TITUBANC='1';
if sexe="2" and (index(TITUREDO_dernier,"E")=0) then TITUBANC='2';
end;
if TITUREDO_dernier ne "" and TITUPRDO_dernier ne "" then do;
if TITUREDO_dernier ne TITUPRDO_dernier then TITUBANC='2';
if index(TITUREDO_dernier,"O")>0 and index(TITUPRDO_dernier,"O")=0 then TITUBANC='4';
if index(TITUREDO_dernier,"E")>0 and index(TITUPRDO_dernier,"E")=0 then TITUBANC='4';
end;
/*Comparaison Revenus d'activit en annuel / RSA /AAH trim*/
attrib COMPANTRIM length=$7. label="EVO REV AN REV TRIM";
COMPANTRIM="AUTRE";
if presconj ne '0' then do;
if revactmo=0 and restraco=0 then COMPANTRIM="STABLE0";else
if revactme=0 and restrace=0 then COMPANTRIM="STABLE0";else
if 0<sum(restraco,restrace)<99999 and sum(revactmo,revactme)=0 then COMPANTRIM="HAUSSE"; else /*ajout 24/06/2016 */
if sum(restraco,restrace)<99999 and sum(revactmo,revactme)<99999 then do;
if (sum(restraco,restrace)*4) / sum(revactmo,revactme)>1.6 then COMPANTRIM="HAUSSE";else
if (sum(restraco,restrace)*4) / sum(revactmo,revactme)<0.4 then COMPANTRIM="BAISSE";else
COMPANTRIM="STABLE";
end;
end;
if presconj = '0' then do;
if sexe='1' then do;
if revactmo=0 and restraco=0 then COMPANTRIM="STABLE0"; else
if revactmo<99999 and restraco<99999 then do;
if revactmo=0 and 0<restraco<99999 then COMPANTRIM="HAUSSE"; else /*ajout 24/06/2016 */
if (restraco*4) / revactmo>1.6 then COMPANTRIM="HAUSSE";else
if (restraco*4) / revactmo<0.4 then COMPANTRIM="BAISSE";else
COMPANTRIM="STABLE";
end;
end;
else do;
if revactme=0 and restrace=0 then COMPANTRIM="STABLE0"; else
if revactme=0 and 0<restrace<99999 then COMPANTRIM="HAUSSE"; else /*ajout 24/06/2016 */
if revactme<99999 and restrace<99999 then do;
if (restrace*4) / revactme>1.6 then COMPANTRIM="HAUSSE";else
if (restrace*4) / revactme<0.4 then COMPANTRIM="BAISSE";else
COMPANTRIM="STABLE";
end;
end;
end;
/*Agrgation indicateurs historiques WEB + Bornes*/
attrib NBWEB18 length=3. label="NB CONNEXIONS WEB+BIW EN 18 MOIS";
NBWEB18=NBCONWEB18; /*Modif octobre 2016 : NBCONWEB18 contient toutes les connexions Web + bornes*/
NBWEB18_quant=put(NBWEB18,NBWEB18_quant.);
label NBWEB18_quant="NOMBRE DE CONNEXIONS WEB+BIW EN 18 MOIS";
RUN;
/******************************************************/
/* RECUEIL DES DONNEES POUR LA CREATION DES SEQUENCES */
/******************************************************/
/*MODIF DSER octobre 2014 : - ajout de CATBEN NE '99' pour viter d'aller chercher des matricules doublons dans les squences
- retrait SITFAM car on l'a dj initialise avec la macro HISTALCAF */
%macro codemens(date);
%do i=1 %to 18 %by 1;
data work.final;
merge work.final (in=a)
Basestat.fre&&m&i. (in=b
keep=MATRICUL CATBEN RSAVERS RESTRAC2 AAHPERE AAHINTA NBENLEFA ASFVERS /*SITFAM ACTRESPD ACTCONJ*/
/*Modification PAC nov2015 : suppression de RSAACT, inutile ici */
where=(CATBEN&&m&i. NE '99')
rename=(CATBEN=CATBEN&&m&i. RSAVERS=RSAVERS&&m&i. RESTRAC2=RESTRAC2&&m&i. AAHPERE=AAHPERE&&m&i. AAHINTA=AAHINTA&&m&i.
ASFVERS=ASFVERS&&m&i. /*SITFAM=FAM&&m&i. ACTRESPD=ACR&&m&i. ACTCONJ=ACJ&&m&i.*/))
/*Modification PAC nov2015 : suppression de RSAACT, inutile ici */ ;
if a=1;
by matricul;
run;
%end;
%mend;
%codemens();
/*************************************************************************/
/** 5- Cration des squences **/
/*************************************************************************/
%macro MP_SEQUENCES();
Data final2 (drop= /*ACJ: ACR:*/FAM: Restrac2: aahinta: aahpere: asfvers: Qualen: Annnen: Moinen:)
/*Modification PAC nov2015 : suppression de RSAACT, inutile ici */;
set final;
/*Squences SITFAM et indicateur*/
array vFAM %do i = 1 %to 18; FAM&&m&i. %end ; ;
attrib SEQFAM length=$5. label="SEQUENCES FAM";
SEQFAM1=vFAM(1); SEQFAM2="X";SEQFAM3="X";SEQFAM4="X";
cpt=1;
do i=2 to 18;
cpt=i+1;
if vFAM(i) ne SEQFAM1 then do; SEQFAM2=vFAM(i); i=18;end;
end;
if cpt<=18 then do i=cpt to 18;
cpt=i+1;
if vFAM(i) ne SEQFAM2 then do; SEQFAM3=vFAM(i); i=18;end;
end;
if cpt<=18 then do i=cpt to 18;
cpt=i+1;
if vFAM(i) ne SEQFAM3 then do; SEQFAM4=vFAM(i);end;
end;
/*Recodage SEQ manquante*/
if SEQFAM1="" then SEQFAM1="0";
if SEQFAM2="" then SEQFAM2="0";
if SEQFAM3="" then SEQFAM3="0";
if SEQFAM4="" then SEQFAM4="0";
/*Indicateur de squence FAM*/
array vseqfam SEQFAM1 SEQFAM2 SEQFAM3 SEQFAM4;
nbX=0;
do i=1 to 4;
if vseqfam(i)="X" then nbX=nbX+1;
end;
if SEQFAM1="1" and nbX=3 then SEQFAM="1_XXX"; else
if SEQFAM1="1" and SEQFAM2="0" and nbX=2 then SEQFAM="1_XXX"; else
if SEQFAM1 in ("2" "3") and nbX=3 then SEQFAM="23XXX"; else
if SEQFAM1 in ("2" "3") and SEQFAM2="0" and nbX=2 then SEQFAM="23XXX"; else
if SEQFAM1="4" and nbX=3 then SEQFAM="4_XXX"; else
if SEQFAM1="4" and SEQFAM2="0" and nbX=2 then SEQFAM="4_XXX"; else
if SEQFAM1 in ("5" "6") and nbX=3 then SEQFAM="56XXX"; else
if SEQFAM1 in ("5" "6") and SEQFAM2="0" and nbX=2 then SEQFAM="56XXX"; else
if SEQFAM1="7" and nbX=3 then SEQFAM="7_XXX"; else
if SEQFAM1="7" and SEQFAM2="0" and nbX=2 then SEQFAM="7_XXX"; else
if SEQFAM1 in ("1") and nbX=2 then SEQFAM="1__XX"; else
if SEQFAM1 in ("4" "5" "6") and nbX=2 then SEQFAM="456XX"; else
if SEQFAM1 in ("2" "3" "7") and nbX=2 then SEQFAM="237XX"; else
if nbX=1 then SEQFAM="__X__";else
SEQFAM="AUTRE";
/*Recodage car pas assez d'obs modles*/
if SEQFAM="237XX" then SEQFAM="RISQ1";
if SEQFAM="1_XXX" then SEQFAM="RISQ1";
if SEQFAM="1__XX" then SEQFAM="RISQ1";
if SEQFAM="56XXX" then SEQFAM="RISQ1";
if SEQFAM="AUTRE" then SEQFAM="456XX";
/*Squences ACR et indicateur*/
array vACR %do i = 1 %to 18; ACR&&m&i. %end ; ;
attrib SEQACR length=$9. label="SEQUENCES ACR";
SEQACR1=vACR(1); SEQACR2="XXX";SEQACR3="XXX";SEQACR4="XXX";
cpt=1;
do i=2 to 18;
cpt=i+1;
if vACR(i) ne "" and vACR(i) ne SEQACR1 then do; SEQACR2=vACR(i); i=18;end;
end;
if cpt<=18 then do i=cpt to 18;
cpt=i+1;
if vACR(i) ne "" and vACR(i) ne SEQACR2 then do; SEQACR3=vACR(i); i=18;end;
end;
if cpt<=18 then do i=cpt to 18;
cpt=i+1;
if vACR(i) ne "" and vACR(i) ne SEQACR3 then do; SEQACR4=vACR(i);end;
end;
/*Recodage SEQACR*/
SEQACRfmt1=put(SEQACR1,$_ACTR.);
SEQACRfmt2=put(SEQACR2,$_ACTR.);
SEQACRfmt3=put(SEQACR3,$_ACTR.);
SEQACRfmt4=put(SEQACR4,$_ACTR.);
/*Indicateur de squence ACR*/
array vseqACR SEQACRfmt1 SEQACRfmt2 SEQACRfmt3 SEQACRfmt4;
nbXXX=0;
do i=1 to 4;
if vseqACR(i)="XXX" then nbXXX=nbXXX+1;
end;
if nbXXX=3 then do;
if SEQACRfmt1 in ("ACT" "ETI" "ETU") then SEQACR="ACT_X__X_";else
if SEQACRfmt1="AUT" then SEQACR="AUT_X__X_";else
if SEQACRfmt1="CHO" then SEQACR="CHO_X__X_";else
if SEQACRfmt1="CON" then SEQACR="CON_X__X_";else
if SEQACRfmt1="INA" then SEQACR="INA_X__X_";else
if SEQACRfmt1="RET" then SEQACR="RET_X__X_";
end;
else if nbXXX=2 then do;
if SEQACRfmt1 in ("ACT" "ETU" "ETI") and countc(SEQACRfmt2,"CHO","INA")>1 then SEQACR="_+__-__X_"; else
if SEQACRfmt1 in ("ACT" "ETU" "ETI") and countc(SEQACRfmt2,"CHO","INA")=0 then SEQACR="_+__=__X_"; else
if SEQACRfmt1 in ("RET" "AUT" "CON") and countc(SEQACRfmt2,"CHO","INA")>1 then SEQACR="_=__-____"; else
if SEQACRfmt1 in ("RET" "AUT" "CON") and countc(SEQACRfmt2,"CHO","INA")=0 then SEQACR="_=__=__X_"; else
if SEQACRfmt1 in ("CHO" "INA" ) and countc(SEQACRfmt2,"CHO","INA")>1 then SEQACR="_-__-__X_"; else
if SEQACRfmt1 in ("RET" "AUT" "CON") and countc(SEQACRfmt2,"CHO","INA")=0 then SEQACR="_-__+__X_";
end;
else if nbXXX=1 then do;
if SEQACRfmt1 in ("ACT" "ETU" "ETI") and countc(SEQACRfmt2,"CHO","INA")>1 then SEQACR="_+__-____"; else
if SEQACRfmt1 in ("ACT" "ETU" "ETI") and countc(SEQACRfmt2,"CHO","INA")=0 then SEQACR="_+__=____"; else
if SEQACRfmt1 in ("RET" "AUT" "CON") and countc(SEQACRfmt2,"CHO","INA")>1 then SEQACR="_=__-____"; else
if SEQACRfmt1 in ("RET" "AUT" "CON") and countc(SEQACRfmt2,"CHO","INA")=0 then SEQACR="_=__=____"; else
if SEQACRfmt1 in ("CHO" "INA" ) and countc(SEQACRfmt2,"CHO","INA")>1 then SEQACR="_-__-____"; else
if SEQACRfmt1 in ("RET" "AUT" "CON") and countc(SEQACRfmt2,"CHO","INA")=0 then SEQACR="_-__+____";
end;
else SEQACR="????????";
/*Recodage car manque d'obs pour les modles*/
if SEQACR="RET_X__X_" then SEQACR="ACT_X__X_";
if SEQACR="AUT_X__X_" then SEQACR="ACT_X__X_";
if SEQACR="CON_X__X_" then SEQACR="????????";
if SEQACR="_+__-__X_" then SEQACR="????????";
if SEQACR="_=__-____" then SEQACR="????????";
if SEQACR="CHO_X__X_" then SEQACR="????????";
if SEQACR="INA_X__X_" then SEQACR="????????";
if SEQACR="_-__-__X_" then SEQACR="_-__-____";
run;
%MEND;
%MP_SEQUENCES;
/* Mise en classe et discrtisation autres variables historiques*/
proc format;
value MOICONTVER_quant
0-<1="0 <1"
1-<4="1 <4"
4-<7="4 <7"
7-<13="7 <13"
13-18 ="13 <=18"
.="MISSAUT"
other="MISSAUT";
value NBCONWEB18_quant
0-<1="0 <1"
1-<4="1 <4"
4-<11="4 <11"
11-<33="11 <33"
33-high ="+ de 33 <=503" /*Modification nov 2015 pour tenir compte des valeurs >503*/
.="MISSAUT"
other="MISSAUT";
value NADRESS18_quant
0-<1="0 <1"
1-<4="1 <4"
4-high="4 +"
.="MISSAUT"
other="MISSAUT";
value FGRESTRI18_quant
0-<1="0 <1"
1-<7="1 <7"
7-<11="7 <11"
11-high="11 +"
/*4-<6="4 <6"*/
/*6-<7="6 <7"*/
/*7-100 ="7 30"*/
/*.="MISSAUT"*/
other="0 <1";
value MOIPIE_NOTINT_quant
/*0-<1="0 <1"
1-<5="1 <5"*/
5-18="5 18"
other="MISSAUT";
value MOIPIE_NPAI_quant
/*0-<1="0 <1"
1-<5="1 <5"
5-<10="5 <10"
10-<14="10 <14"
14-18 ="14 <=18"*/
/*0-4="00 04"*/
0-<1="00"
1-<5="1 <5"
5-18="05 18"
other="00";
RUN;
data work.final2;
set work.final2;
FGRESTRI18_quant=put(FGRESTRI18,FGRESTRI18_quant.); label FGRESTRI18_quant="NB FG RESTRI (HORS ANNULES) SUR 18 MOIS";
MOICONTVER_quant=put(MOICONTVER,MOICONTVER_quant.); label MOICONTVER_quant="NB MOIS DEPUIS DERNIER CONTRLE VERIF";
MOIPIE_NOTINT_quant=put(MOIPIE_NOTINT,MOIPIE_NOTINT_quant.); label MOIPIE_NOTINT_quant="NB MOIS DEPUIS PIECE NOTINT";
MOIPIE_NPAI_quant=put(MOIPIE_NPAI,MOIPIE_NPAI_quant.); label MOIPIE_NPAI_quant="NB MOIS DEPUIS PIECE MNPAI";
NADRESS18_quant=put(NADRESS18,NADRESS18_quant.); label NADRESS18_quant="NB CHGT ADRESSE 18 MOIS";
*------------------------------------------------------------*;
* Computed Code;
*------------------------------------------------------------*;
*------------------------------------------------------------*;
* TRANSFORM: MACT12 , Optimal Binning(4);
*------------------------------------------------------------*;
label OPT_MACT12 = 'Transformed MACT12';
length OPT_MACT12 $19;
if (MACT12 < 0.5) then
OPT_MACT12 = "01:low -0.5, MISSING";
else
if (MACT12 >= 0.5 and MACT12 < 14.5) then
OPT_MACT12 = "02:0.5-14.5";
else
if (MACT12 >= 14.5) then
OPT_MACT12 = "03:14.5-high";
*------------------------------------------------------------*;
* TRANSFORM: NMODLOY18 , Optimal Binning(4);
*------------------------------------------------------------*;
label OPT_NMODLOY18 = 'Transformed: NB MOD MT LOY EN 18 MOIS';
length OPT_NMODLOY18 $19;
if (NMODLOY18 < 0.5) then
OPT_NMODLOY18 = "01:low -0.5, MISSING";
else
if (NMODLOY18 >= 0.5 and NMODLOY18 < 4.5) then
OPT_NMODLOY18 = "02:0.5-4.5";
else
if (NMODLOY18 >= 4.5) then
OPT_NMODLOY18 = "03:4.5-high";
*------------------------------------------------------------*;
* TRANSFORM: FGORINET12 , Optimal Binning(4);
*------------------------------------------------------------*;
label OPT_FGORINET12 = 'Transformed FGORINET12';
length OPT_FGORINET12 $19;
if (FGORINET12 < 0.5) then
OPT_FGORINET12 = "01:low -0.5, MISSING";
else
if (FGORINET12 >= 0.5 and FGORINET12 < 2.5) then
OPT_FGORINET12 = "02:0.5-2.5";
else
if (FGORINET12 >= 2.5 and FGORINET12 < 5.5) then
OPT_FGORINET12 = "03:2.5-5.5";
else
if (FGORINET12 >= 5.5) then
OPT_FGORINET12 = "04:5.5-high";
*------------------------------------------------------------*;
* TRANSFORM: FGORIREC18 , Optimal Binning(4);
*------------------------------------------------------------*;
label OPT_FGORIREC18 = 'Transformed FGORIREC18';
length OPT_FGORIREC18 $19;
if (FGORIREC18 < 0.5) then
OPT_FGORIREC18 = "01:low -0.5, MISSING";
else
if (FGORIREC18 >= 0.5) then
OPT_FGORIREC18 = "02:0.5-high";
*------------------------------------------------------------*;
* TRANSFORM: MOIFGRESAN , Optimal Binning(4);
*------------------------------------------------------------*;
label OPT_MOIFGRESAN = 'Transformed MOIFGRESAN';
length OPT_MOIFGRESAN $11;
if (MOIFGRESAN eq .) then OPT_MOIFGRESAN='_MISSING_';
else
if (MOIFGRESAN < 0.5) then
OPT_MOIFGRESAN = "01:low -0.5";
else
if (MOIFGRESAN >= 0.5 and MOIFGRESAN < 4.5) then
OPT_MOIFGRESAN = "02:0.5-4.5";
else
if (MOIFGRESAN eq . ) or (MOIFGRESAN >= 4.5) then
OPT_MOIFGRESAN = "03:4.5-high, MISSING";
*------------------------------------------------------------*;
* TRANSFORM: MOIONTAVU , Optimal Binning(4);
*------------------------------------------------------------*;
label OPT_MOIONTAVU = 'Transformed MOIONTAVU';
length OPT_MOIONTAVU $19;
if (MOIONTAVU < 0.5) then
OPT_MOIONTAVU = "01:low -0.5, MISSING";
else
if (MOIONTAVU >= 0.5 and MOIONTAVU < 1.5) then
OPT_MOIONTAVU = "02:0.5-1.5";
else
if (MOIONTAVU >= 1.5) then
OPT_MOIONTAVU = "03:1.5-high";
*------------------------------------------------------------*;
* TRANSFORM: MOIPIE_DSIT , Optimal Binning(4);
*------------------------------------------------------------*;
label OPT_MOIPIE_DSIT = 'Transformed MOIPIE_DSIT';
length OPT_MOIPIE_DSIT $19;
if (MOIPIE_DSIT < 5.5) then
OPT_MOIPIE_DSIT = "01:low -5.5, MISSING";
else
if (MOIPIE_DSIT >= 5.5) then
OPT_MOIPIE_DSIT = "02:5.5-high";
*------------------------------------------------------------*;
* TRANSFORM: MOIPIE_MAIL , Optimal Binning(4);
*------------------------------------------------------------*;
label OPT_MOIPIE_MAIL = 'Transformed MOIPIE_MAIL';
length OPT_MOIPIE_MAIL $19;
if (MOIPIE_MAIL < 2.5) then
OPT_MOIPIE_MAIL = "01:low -2.5, MISSING";
else
if (MOIPIE_MAIL >= 2.5 and MOIPIE_MAIL < 4.5) then
OPT_MOIPIE_MAIL = "02:2.5-4.5";
else
if (MOIPIE_MAIL >= 4.5) then
OPT_MOIPIE_MAIL = "03:4.5-high";
*------------------------------------------------------------*;
* TRANSFORM: NBPIE_DSIT18 , Optimal Binning(4);
*------------------------------------------------------------*;
label OPT_NBPIE_DSIT18 = 'Transformed NBPIE_DSIT18';
length OPT_NBPIE_DSIT18 $19;
if (NBPIE_DSIT18 < 0.5) then
OPT_NBPIE_DSIT18 = "01:low -0.5, MISSING";
else
if (NBPIE_DSIT18 >= 0.5) then
OPT_NBPIE_DSIT18 = "02:0.5-high";
*------------------------------------------------------------*;
* TRANSFORM: NBPIE_MAIL18 , Optimal Binning(4);
*------------------------------------------------------------*;
label OPT_NBPIE_MAIL18 = 'Transformed NBPIE_MAIL18';
length OPT_NBPIE_MAIL18 $19;
if (NBPIE_MAIL18 < 1.5) then
OPT_NBPIE_MAIL18 = "01:low -1.5, MISSING";
else
if (NBPIE_MAIL18 >= 1.5) then
OPT_NBPIE_MAIL18 = "02:1.5-high";
RUN;
data newtableB_scoree_&m1.;
set final2 (Keep = MATRICUL NORDALLC NUMCAF MS NADRESS18_quant OPT_MACT12 OPT_NMODLOY18 OPT_MACT12 FGRESTRI18_quant
OPT_FGORINET12 OPT_FGORIREC18
OPT_MOIFGRESAN MOICONTVER_quant
NBWEB18_quant OPT_MOIONTAVU MOIPIE_NOTINT_quant
MOIPIE_NPAI_quant OPT_MOIPIE_DSIT
OPT_MOIPIE_MAIL OPT_NBPIE_DSIT18 OPT_NBPIE_MAIL18
ABANEU agecon_quant ageresp_quant MOINSCDO_quant
MTPAJCAV_quant NBM_ODMS_quant RUC_RED_quant STATUETU TITUBANC
topen19 topen19 TOPENF1218_P tut_P TXEFF_P TYPAAH
COMPANTRIM SEQACR SEQFAM );
run;
/********************************************************************************/
/********************************************************************************/
/* DERNIERE ETAPE : SCORING */
/********************************************************************************/
/********************************************************************************/
/*MODIF DSER octobre 2014 : Nouveaux paramtrages de scoring aprs nouvelle modlisation
Le nom de la variable cible change*/
%macro scoreglob2;
*************************************;
*** begin scoring code for regression;
*************************************;
length _WARN_ $4;
label _WARN_ = 'Warnings' ;
length I_cible $ 13;
label I_cible = 'Into: cible' ;
*** Target Values;
array REGDRF [2] $13 _temporary_ ('INDSOLD4M200E' '0REGUL' );
label U_cible = 'Unnormalized Into: cible' ;
length U_cible $ 13;
*** Unnormalized target values;
array REGDRU[2] $ 13 _temporary_ ('INDSOLD4M200E' '0REGUL ' );
drop _DM_BAD;
_DM_BAD=0;
*** Check topen19 for missing values ;
if missing( topen19 ) then do;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
*** Generate dummy variables for ABANEU ;
drop _1_0 ;
if missing( ABANEU ) then do;
_1_0 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm15 $ 15; drop _dm15 ;
%DMNORMCP( ABANEU , _dm15 )
if _dm15 = 'AUCUN' then do;
_1_0 = -1;
end;
else if _dm15 = 'AB. OU NEUTRAL.' then do;
_1_0 = 1;
end;
else do;
_1_0 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for COMPANTRIM ;
drop _2_0 _2_1 _2_2 _2_3 ;
*** encoding is sparse, initialize to zero;
_2_0 = 0;
_2_1 = 0;
_2_2 = 0;
_2_3 = 0;
if missing( COMPANTRIM ) then do;
_2_0 = .;
_2_1 = .;
_2_2 = .;
_2_3 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm7 $ 7; drop _dm7 ;
%DMNORMCP( COMPANTRIM , _dm7 )
if _dm7 = 'AUTRE' then do;
_2_0 = 1;
end;
else if _dm7 = 'STABLE0' then do;
_2_0 = -1;
_2_1 = -1;
_2_2 = -1;
_2_3 = -1;
end;
else if _dm7 = 'BAISSE' then do;
_2_1 = 1;
end;
else if _dm7 = 'STABLE' then do;
_2_3 = 1;
end;
else if _dm7 = 'HAUSSE' then do;
_2_2 = 1;
end;
else do;
_2_0 = .;
_2_1 = .;
_2_2 = .;
_2_3 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for FGRESTRI18_quant ;
drop _3_0 _3_1 _3_2 ;
if missing( FGRESTRI18_quant ) then do;
_3_0 = .;
_3_1 = .;
_3_2 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm7 $ 7; drop _dm7 ;
%DMNORMCP( FGRESTRI18_quant , _dm7 )
if _dm7 = '0 <1' then do;
_3_0 = 1;
_3_1 = 0;
_3_2 = 0;
end;
else if _dm7 = '1 <7' then do;
_3_0 = 0;
_3_1 = 1;
_3_2 = 0;
end;
else if _dm7 = '7 <11' then do;
_3_0 = -1;
_3_1 = -1;
_3_2 = -1;
end;
else if _dm7 = '11 +' then do;
_3_0 = 0;
_3_1 = 0;
_3_2 = 1;
end;
else do;
_3_0 = .;
_3_1 = .;
_3_2 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for MOICONTVER_quant ;
drop _4_0 _4_1 _4_2 _4_3 ;
*** encoding is sparse, initialize to zero;
_4_0 = 0;
_4_1 = 0;
_4_2 = 0;
_4_3 = 0;
if missing( MOICONTVER_quant ) then do;
_4_0 = .;
_4_1 = .;
_4_2 = .;
_4_3 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm9 $ 9; drop _dm9 ;
%DMNORMCP( MOICONTVER_quant , _dm9 )
if _dm9 = 'MISSAUT' then do;
_4_0 = -1;
_4_1 = -1;
_4_2 = -1;
_4_3 = -1;
end;
else if _dm9 = '7 <13' then do;
_4_3 = 1;
end;
else if _dm9 = '4 <7' then do;
_4_2 = 1;
end;
else if _dm9 = '13 <=18' then do;
_4_1 = 1;
end;
else if _dm9 = '1 <4' then do;
_4_0 = 1;
end;
else do;
_4_0 = .;
_4_1 = .;
_4_2 = .;
_4_3 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for MOINSCDO_quant ;
drop _5_0 _5_1 ;
if missing( MOINSCDO_quant ) then do;
_5_0 = .;
_5_1 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm10 $ 10; drop _dm10 ;
%DMNORMCP( MOINSCDO_quant , _dm10 )
if _dm10 = '49 ET PLUS' then do;
_5_0 = -1;
_5_1 = -1;
end;
else if _dm10 = '12 <49' then do;
_5_0 = 0;
_5_1 = 1;
end;
else if _dm10 = '0 <12' then do;
_5_0 = 1;
_5_1 = 0;
end;
else do;
_5_0 = .;
_5_1 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for MOIPIE_NOTINT_quant ;
drop _6_0 ;
if missing( MOIPIE_NOTINT_quant ) then do;
_6_0 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm7 $ 7; drop _dm7 ;
%DMNORMCP( MOIPIE_NOTINT_quant , _dm7 )
if _dm7 = 'MISSAUT' then do;
_6_0 = -1;
end;
else if _dm7 = '5 18' then do;
_6_0 = 1;
end;
else do;
_6_0 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for MOIPIE_NPAI_quant ;
drop _7_0 _7_1 ;
if missing( MOIPIE_NPAI_quant ) then do;
_7_0 = .;
_7_1 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm7 $ 7; drop _dm7 ;
%DMNORMCP( MOIPIE_NPAI_quant , _dm7 )
if _dm7 = '00' then do;
_7_0 = 1;
_7_1 = 0;
end;
else if _dm7 = '05 18' then do;
_7_0 = 0;
_7_1 = 1;
end;
else if _dm7 = '1 <5' then do;
_7_0 = -1;
_7_1 = -1;
end;
else do;
_7_0 = .;
_7_1 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for MTPAJCAV_quant ;
drop _8_0 _8_1 ;
if missing( MTPAJCAV_quant ) then do;
_8_0 = .;
_8_1 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm7 $ 7; drop _dm7 ;
%DMNORMCP( MTPAJCAV_quant , _dm7 )
if _dm7 = '0' then do;
_8_0 = 1;
_8_1 = 0;
end;
else if _dm7 = '361 ET+' then do;
_8_0 = -1;
_8_1 = -1;
end;
else if _dm7 = '0 361' then do;
_8_0 = 0;
_8_1 = 1;
end;
else do;
_8_0 = .;
_8_1 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for NADRESS18_quant ;
drop _9_0 _9_1 ;
if missing( NADRESS18_quant ) then do;
_9_0 = .;
_9_1 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm7 $ 7; drop _dm7 ;
%DMNORMCP( NADRESS18_quant , _dm7 )
if _dm7 = '0 <1' then do;
_9_0 = 1;
_9_1 = 0;
end;
else if _dm7 = '4 +' then do;
_9_0 = -1;
_9_1 = -1;
end;
else if _dm7 = '1 <4' then do;
_9_0 = 0;
_9_1 = 1;
end;
else do;
_9_0 = .;
_9_1 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for NBM_ODMS_quant ;
drop _10_0 _10_1 _10_2 ;
if missing( NBM_ODMS_quant ) then do;
_10_0 = .;
_10_1 = .;
_10_2 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm8 $ 8; drop _dm8 ;
%DMNORMCP( NBM_ODMS_quant , _dm8 )
if _dm8 = '0 <1' then do;
_10_0 = 1;
_10_1 = 0;
_10_2 = 0;
end;
else if _dm8 = '32 500' then do;
_10_0 = -1;
_10_1 = -1;
_10_2 = -1;
end;
else if _dm8 = '13 <32' then do;
_10_0 = 0;
_10_1 = 0;
_10_2 = 1;
end;
else if _dm8 = '1 <13' then do;
_10_0 = 0;
_10_1 = 1;
_10_2 = 0;
end;
else do;
_10_0 = .;
_10_1 = .;
_10_2 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for NBWEB18_quant ;
drop _11_0 _11_1 _11_2 ;
if missing( NBWEB18_quant ) then do;
_11_0 = .;
_11_1 = .;
_11_2 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm10 $ 10; drop _dm10 ;
%DMNORMCP( NBWEB18_quant , _dm10 )
if _dm10 = '0 <4' then do;
_11_0 = 1;
_11_1 = 0;
_11_2 = 0;
end;
else if _dm10 = '4 <12' then do;
_11_0 = -1;
_11_1 = -1;
_11_2 = -1;
end;
else if _dm10 = '12 <34' then do;
_11_0 = 0;
_11_1 = 1;
_11_2 = 0;
end;
else if _dm10 = '34 <=504' then do;
_11_0 = 0;
_11_1 = 0;
_11_2 = 1;
end;
else do;
_11_0 = .;
_11_1 = .;
_11_2 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for OPT_FGORINET12 ;
drop _14_0 _14_1 _14_2 ;
if missing( OPT_FGORINET12 ) then do;
_14_0 = .;
_14_1 = .;
_14_2 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm19 $ 19; drop _dm19 ;
%DMNORMCP( OPT_FGORINET12 , _dm19 )
if _dm19 = '01:LOW -0.5, MISSIN' then do;
_14_0 = 1;
_14_1 = 0;
_14_2 = 0;
end;
else if _dm19 = '02:0.5-2.5' then do;
_14_0 = 0;
_14_1 = 1;
_14_2 = 0;
end;
else if _dm19 = '03:2.5-5.5' then do;
_14_0 = 0;
_14_1 = 0;
_14_2 = 1;
end;
else if _dm19 = '04:5.5-HIGH' then do;
_14_0 = -1;
_14_1 = -1;
_14_2 = -1;
end;
else do;
_14_0 = .;
_14_1 = .;
_14_2 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for OPT_FGORIREC18 ;
drop _15_0 ;
if missing( OPT_FGORIREC18 ) then do;
_15_0 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm19 $ 19; drop _dm19 ;
%DMNORMCP( OPT_FGORIREC18 , _dm19 )
if _dm19 = '01:LOW -0.5, MISSIN' then do;
_15_0 = 1;
end;
else if _dm19 = '02:0.5-HIGH' then do;
_15_0 = -1;
end;
else do;
_15_0 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for OPT_MACT12 ;
drop _16_0 _16_1 ;
if missing( OPT_MACT12 ) then do;
_16_0 = .;
_16_1 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm19 $ 19; drop _dm19 ;
%DMNORMCP( OPT_MACT12 , _dm19 )
if _dm19 = '01:LOW -0.5, MISSIN' then do;
_16_0 = 1;
_16_1 = 0;
end;
else if _dm19 = '02:0.5-14.5' then do;
_16_0 = 0;
_16_1 = 1;
end;
else if _dm19 = '03:14.5-HIGH' then do;
_16_0 = -1;
_16_1 = -1;
end;
else do;
_16_0 = .;
_16_1 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for OPT_MOIFGRESAN ;
drop _17_0 _17_1 ;
if missing( OPT_MOIFGRESAN ) then do;
_17_0 = .;
_17_1 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm11 $ 11; drop _dm11 ;
%DMNORMCP( OPT_MOIFGRESAN , _dm11 )
if _dm11 = '03:4.5-HIGH' then do;
_17_0 = -1;
_17_1 = -1;
end;
else if _dm11 = '02:0.5-4.5' then do;
_17_0 = 0;
_17_1 = 1;
end;
else if _dm11 = '01:LOW -0.5' then do;
_17_0 = 1;
_17_1 = 0;
end;
else do;
_17_0 = .;
_17_1 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for OPT_MOIONTAVU ;
drop _18_0 _18_1 ;
if missing( OPT_MOIONTAVU ) then do;
_18_0 = .;
_18_1 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm19 $ 19; drop _dm19 ;
%DMNORMCP( OPT_MOIONTAVU , _dm19 )
if _dm19 = '01:LOW -0.5, MISSIN' then do;
_18_0 = 1;
_18_1 = 0;
end;
else if _dm19 = '03:1.5-HIGH' then do;
_18_0 = -1;
_18_1 = -1;
end;
else if _dm19 = '02:0.5-1.5' then do;
_18_0 = 0;
_18_1 = 1;
end;
else do;
_18_0 = .;
_18_1 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for OPT_MOIPIE_DSIT ;
drop _19_0 ;
if missing( OPT_MOIPIE_DSIT ) then do;
_19_0 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm19 $ 19; drop _dm19 ;
%DMNORMCP( OPT_MOIPIE_DSIT , _dm19 )
if _dm19 = '01:LOW -5.5, MISSIN' then do;
_19_0 = 1;
end;
else if _dm19 = '02:5.5-HIGH' then do;
_19_0 = -1;
end;
else do;
_19_0 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for OPT_MOIPIE_MAIL ;
drop _20_0 _20_1 ;
if missing( OPT_MOIPIE_MAIL ) then do;
_20_0 = .;
_20_1 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm19 $ 19; drop _dm19 ;
%DMNORMCP( OPT_MOIPIE_MAIL , _dm19 )
if _dm19 = '01:LOW -2.5, MISSIN' then do;
_20_0 = 1;
_20_1 = 0;
end;
else if _dm19 = '03:4.5-HIGH' then do;
_20_0 = -1;
_20_1 = -1;
end;
else if _dm19 = '02:2.5-4.5' then do;
_20_0 = 0;
_20_1 = 1;
end;
else do;
_20_0 = .;
_20_1 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for OPT_NBPIE_DSIT18 ;
drop _21_0 ;
if missing( OPT_NBPIE_DSIT18 ) then do;
_21_0 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm19 $ 19; drop _dm19 ;
%DMNORMCP( OPT_NBPIE_DSIT18 , _dm19 )
if _dm19 = '01:LOW -0.5, MISSIN' then do;
_21_0 = 1;
end;
else if _dm19 = '02:0.5-HIGH' then do;
_21_0 = -1;
end;
else do;
_21_0 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for OPT_NBPIE_MAIL18 ;
drop _22_0 ;
if missing( OPT_NBPIE_MAIL18 ) then do;
_22_0 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm19 $ 19; drop _dm19 ;
%DMNORMCP( OPT_NBPIE_MAIL18 , _dm19 )
if _dm19 = '01:LOW -1.5, MISSIN' then do;
_22_0 = 1;
end;
else if _dm19 = '02:1.5-HIGH' then do;
_22_0 = -1;
end;
else do;
_22_0 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for OPT_NMODLOY18 ;
drop _23_0 _23_1 ;
if missing( OPT_NMODLOY18 ) then do;
_23_0 = .;
_23_1 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm19 $ 19; drop _dm19 ;
%DMNORMCP( OPT_NMODLOY18 , _dm19 )
if _dm19 = '01:LOW -0.5, MISSIN' then do;
_23_0 = 1;
_23_1 = 0;
end;
else if _dm19 = '02:0.5-4.5' then do;
_23_0 = 0;
_23_1 = 1;
end;
else if _dm19 = '03:4.5-HIGH' then do;
_23_0 = -1;
_23_1 = -1;
end;
else do;
_23_0 = .;
_23_1 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for RUC_RED_quant ;
drop _24_0 _24_1 _24_2 ;
if missing( RUC_RED_quant ) then do;
_24_0 = .;
_24_1 = .;
_24_2 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm17 $ 17; drop _dm17 ;
%DMNORMCP( RUC_RED_quant , _dm17 )
if _dm17 = '0 <577' then do;
_24_0 = 1;
_24_1 = 0;
_24_2 = 0;
end;
else if _dm17 = '942 <1483.33' then do;
_24_0 = -1;
_24_1 = -1;
_24_2 = -1;
end;
else if _dm17 = '577 <942' then do;
_24_0 = 0;
_24_1 = 0;
_24_2 = 1;
end;
else if _dm17 = '1483.33 <=19745' then do;
_24_0 = 0;
_24_1 = 1;
_24_2 = 0;
end;
else do;
_24_0 = .;
_24_1 = .;
_24_2 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for SEQACR ;
drop _25_0 _25_1 _25_2 ;
if missing( SEQACR ) then do;
_25_0 = .;
_25_1 = .;
_25_2 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm9 $ 9; drop _dm9 ;
%DMNORMCP( SEQACR , _dm9 )
if _dm9 = 'ACT_X__X_' then do;
_25_0 = 0;
_25_1 = 1;
_25_2 = 0;
end;
else if _dm9 = '????????' then do;
_25_0 = 1;
_25_1 = 0;
_25_2 = 0;
end;
else if _dm9 = '_-__-____' then do;
_25_0 = -1;
_25_1 = -1;
_25_2 = -1;
end;
else if _dm9 = '_+__-____' then do;
_25_0 = 0;
_25_1 = 0;
_25_2 = 1;
end;
else do;
_25_0 = .;
_25_1 = .;
_25_2 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for SEQFAM ;
drop _27_0 _27_1 _27_2 _27_3 _27_4 ;
*** encoding is sparse, initialize to zero;
_27_0 = 0;
_27_1 = 0;
_27_2 = 0;
_27_3 = 0;
_27_4 = 0;
if missing( SEQFAM ) then do;
_27_0 = .;
_27_1 = .;
_27_2 = .;
_27_3 = .;
_27_4 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm5 $ 5; drop _dm5 ;
%DMNORMCP( SEQFAM , _dm5 )
if _dm5 = 'RISQ1' then do;
_27_4 = 1;
end;
else if _dm5 = '23XXX' then do;
_27_0 = 1;
end;
else if _dm5 = '4_XXX' then do;
_27_2 = 1;
end;
else if _dm5 = '7_XXX' then do;
_27_3 = 1;
end;
else if _dm5 = '456XX' then do;
_27_1 = 1;
end;
else if _dm5 = '__X__' then do;
_27_0 = -1;
_27_1 = -1;
_27_2 = -1;
_27_3 = -1;
_27_4 = -1;
end;
else do;
_27_0 = .;
_27_1 = .;
_27_2 = .;
_27_3 = .;
_27_4 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for STATUETU ;
drop _28_0 _28_1 ;
if missing( STATUETU ) then do;
_28_0 = .;
_28_1 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm1 $ 1; drop _dm1 ;
%DMNORMCP( STATUETU , _dm1 )
if _dm1 = '0' then do;
_28_0 = 1;
_28_1 = 0;
end;
else if _dm1 = '1' then do;
_28_0 = 0;
_28_1 = 1;
end;
else if _dm1 = '3' then do;
_28_0 = -1;
_28_1 = -1;
end;
else do;
_28_0 = .;
_28_1 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for TITUBANC ;
drop _29_0 _29_1 ;
if missing( TITUBANC ) then do;
_29_0 = .;
_29_1 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm1 $ 1; drop _dm1 ;
%DMNORMCP( TITUBANC , _dm1 )
if _dm1 = '1' then do;
_29_0 = 1;
_29_1 = 0;
end;
else if _dm1 = '2' then do;
_29_0 = 0;
_29_1 = 1;
end;
else if _dm1 = '4' then do;
_29_0 = -1;
_29_1 = -1;
end;
else do;
_29_0 = .;
_29_1 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for TOPENF1218_P ;
drop _30_0 ;
if missing( TOPENF1218_P ) then do;
_30_0 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm1 $ 1; drop _dm1 ;
%DMNORMCP( TOPENF1218_P , _dm1 )
if _dm1 = '0' then do;
_30_0 = 1;
end;
else if _dm1 = '1' then do;
_30_0 = -1;
end;
else do;
_30_0 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for TXEFF_P ;
drop _31_0 ;
if missing( TXEFF_P ) then do;
_31_0 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm15 $ 15; drop _dm15 ;
%DMNORMCP( TXEFF_P , _dm15 )
if _dm15 = '0ALETTXEFF 0A35' then do;
_31_0 = 1;
end;
else if _dm15 = '35ETPLUS' then do;
_31_0 = -1;
end;
else do;
_31_0 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for TYPAAH ;
drop _32_0 _32_1 ;
if missing( TYPAAH ) then do;
_32_0 = .;
_32_1 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm1 $ 1; drop _dm1 ;
%DMNORMCP( TYPAAH , _dm1 )
if _dm1 = '0' then do;
_32_0 = 1;
_32_1 = 0;
end;
else if _dm1 = '2' then do;
_32_0 = -1;
_32_1 = -1;
end;
else if _dm1 = '1' then do;
_32_0 = 0;
_32_1 = 1;
end;
else do;
_32_0 = .;
_32_1 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for agecon_quant ;
drop _33_0 ;
if missing( agecon_quant ) then do;
_33_0 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm10 $ 10; drop _dm10 ;
%DMNORMCP( agecon_quant , _dm10 )
if _dm10 = 'MISSAUT' then do;
_33_0 = -1;
end;
else if _dm10 = '60 ET PLUS' then do;
_33_0 = 1;
end;
else do;
_33_0 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for ageresp_quant ;
drop _34_0 ;
if missing( ageresp_quant ) then do;
_34_0 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm7 $ 7; drop _dm7 ;
%DMNORMCP( ageresp_quant , _dm7 )
if _dm7 = 'MISSAUT' then do;
_34_0 = -1;
end;
else if _dm7 = '00 33' then do;
_34_0 = 1;
end;
else do;
_34_0 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** Generate dummy variables for tut_P ;
drop _35_0 ;
if missing( tut_P ) then do;
_35_0 = .;
substr(_warn_,1,1) = 'M';
_DM_BAD = 1;
end;
else do;
length _dm7 $ 7; drop _dm7 ;
%DMNORMCP( tut_P , _dm7 )
if _dm7 = '0' then do;
_35_0 = 1;
end;
else if _dm7 = 'TUTELLE' then do;
_35_0 = -1;
end;
else do;
_35_0 = .;
substr(_warn_,2,1) = 'U';
_DM_BAD = 1;
end;
end;
*** If missing inputs, use averages;
if _DM_BAD > 0 then do;
_P0 = 0.110033884;
_P1 = 0.889966116;
goto REGDR1;
end;
*** Compute Linear Predictor;
drop _TEMP;
drop _LP0 ;
_LP0 = 0;
*** Effect: ABANEU ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.23232764382303) * _TEMP * _1_0;
*** Effect: COMPANTRIM ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.2213879461932) * _TEMP * _2_0;
_LP0 = _LP0 + ( -0.23758864170547) * _TEMP * _2_1;
_LP0 = _LP0 + ( 0.10014517695226) * _TEMP * _2_2;
_LP0 = _LP0 + ( 0.28214016541774) * _TEMP * _2_3;
*** Effect: FGRESTRI18_quant ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.25528218660984) * _TEMP * _3_0;
_LP0 = _LP0 + ( -0.03407843771333) * _TEMP * _3_1;
_LP0 = _LP0 + ( 0.24828745194934) * _TEMP * _3_2;
*** Effect: MOICONTVER_quant ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.21768333198141) * _TEMP * _4_0;
_LP0 = _LP0 + ( 0.09656226810839) * _TEMP * _4_1;
_LP0 = _LP0 + ( 0.3753744654792) * _TEMP * _4_2;
_LP0 = _LP0 + ( -0.21053899338984) * _TEMP * _4_3;
*** Effect: MOINSCDO_quant ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.37223848913268) * _TEMP * _5_0;
_LP0 = _LP0 + ( 0.22711099427676) * _TEMP * _5_1;
*** Effect: MOIPIE_NOTINT_quant ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.4409911195616) * _TEMP * _6_0;
*** Effect: MOIPIE_NPAI_quant ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.10801749528109) * _TEMP * _7_0;
_LP0 = _LP0 + ( 0.30748094150248) * _TEMP * _7_1;
*** Effect: MTPAJCAV_quant ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.19975598506804) * _TEMP * _8_0;
_LP0 = _LP0 + ( 0.02474201858734) * _TEMP * _8_1;
*** Effect: NADRESS18_quant ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.32426185988357) * _TEMP * _9_0;
_LP0 = _LP0 + ( -0.45225170547949) * _TEMP * _9_1;
*** Effect: NBM_ODMS_quant ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.39791200043493) * _TEMP * _10_0;
_LP0 = _LP0 + ( -0.20817360952199) * _TEMP * _10_1;
_LP0 = _LP0 + ( 0.32033067809115) * _TEMP * _10_2;
*** Effect: NBWEB18_quant ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.02477883999277) * _TEMP * _11_0;
_LP0 = _LP0 + ( -0.11336860212259) * _TEMP * _11_1;
_LP0 = _LP0 + ( -0.05326803815191) * _TEMP * _11_2;
*** Effect: OPT_FGORINET12 ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.16773363709676) * _TEMP * _14_0;
_LP0 = _LP0 + ( 0.01415184255654) * _TEMP * _14_1;
_LP0 = _LP0 + ( -0.13428969940581) * _TEMP * _14_2;
*** Effect: OPT_FGORIREC18 ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.15511757943741) * _TEMP * _15_0;
*** Effect: OPT_MACT12 ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.27730925279732) * _TEMP * _16_0;
_LP0 = _LP0 + ( 0.32522331141171) * _TEMP * _16_1;
*** Effect: OPT_MOIFGRESAN ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.81202850635466) * _TEMP * _17_0;
_LP0 = _LP0 + ( 0.61923386123076) * _TEMP * _17_1;
*** Effect: OPT_MOIONTAVU ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.13627815941635) * _TEMP * _18_0;
_LP0 = _LP0 + ( -0.04374801754763) * _TEMP * _18_1;
*** Effect: OPT_MOIPIE_DSIT ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.3597481037668) * _TEMP * _19_0;
*** Effect: OPT_MOIPIE_MAIL ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.15537483693343) * _TEMP * _20_0;
_LP0 = _LP0 + ( 0.37315035245438) * _TEMP * _20_1;
*** Effect: OPT_NBPIE_DSIT18 ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.29525355588199) * _TEMP * _21_0;
*** Effect: OPT_NBPIE_MAIL18 ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.13623828752591) * _TEMP * _22_0;
*** Effect: OPT_NMODLOY18 ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.54676525776417) * _TEMP * _23_0;
_LP0 = _LP0 + ( -0.31601088054791) * _TEMP * _23_1;
*** Effect: RUC_RED_quant ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.33484019169728) * _TEMP * _24_0;
_LP0 = _LP0 + ( -0.79175797044132) * _TEMP * _24_1;
_LP0 = _LP0 + ( 0.43094626466292) * _TEMP * _24_2;
*** Effect: SEQACR ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.11009895761839) * _TEMP * _25_0;
_LP0 = _LP0 + ( 0.01494576600753) * _TEMP * _25_1;
_LP0 = _LP0 + ( -0.35411923214215) * _TEMP * _25_2;
*** Effect: SEQFAM ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.02688244090902) * _TEMP * _27_0;
_LP0 = _LP0 + ( 0.66925439399747) * _TEMP * _27_1;
_LP0 = _LP0 + ( -0.63687561103914) * _TEMP * _27_2;
_LP0 = _LP0 + ( -0.49280197200267) * _TEMP * _27_3;
_LP0 = _LP0 + ( 0.125581957456) * _TEMP * _27_4;
*** Effect: STATUETU ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.26847813628468) * _TEMP * _28_0;
_LP0 = _LP0 + ( -0.49231217017174) * _TEMP * _28_1;
*** Effect: TITUBANC ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.2042472331848) * _TEMP * _29_0;
_LP0 = _LP0 + ( -0.30962992811117) * _TEMP * _29_1;
*** Effect: TOPENF1218_P ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.08779929863942) * _TEMP * _30_0;
*** Effect: TXEFF_P ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.09635968487988) * _TEMP * _31_0;
*** Effect: TYPAAH ;
_TEMP = 1;
_LP0 = _LP0 + ( -0.21025373930299) * _TEMP * _32_0;
_LP0 = _LP0 + ( 0.72818206088848) * _TEMP * _32_1;
*** Effect: agecon_quant ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.27722626019663) * _TEMP * _33_0;
*** Effect: ageresp_quant ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.11334632521637) * _TEMP * _34_0;
*** Effect: topen19 ;
_TEMP = topen19 ;
_LP0 = _LP0 + ( 0.89385926213357 * _TEMP);
*** Effect: tut_P ;
_TEMP = 1;
_LP0 = _LP0 + ( 0.60450601197118) * _TEMP * _35_0;
*** Naive Posterior Probabilities;
drop _MAXP _IY _P0 _P1;
drop _LPMAX;
_LPMAX= 0;
_LP0 = -1.73654727320913 + _LP0;
if _LPMAX < _LP0 then _LPMAX = _LP0;
_LP0 = exp(_LP0 - _LPMAX);
_LPMAX = exp(-_LPMAX);
_P1 = 1 / (_LPMAX + _LP0);
_P0 = _LP0 * _P1;
_P1 = _LPMAX * _P1;
REGDR1:
*** Posterior Probabilities and Predicted Level;
label P_cibleINDSOLD4M200E = 'Predicted: cible=INDSOLD4M200E' ;
label P_cible0REGUL = 'Predicted: cible=0REGUL' ;
P_cibleINDSOLD4M200E = _P0;
_MAXP = _P0;
_IY = 1;
P_cible0REGUL = _P1;
if (_P1 - _MAXP > 1e-8) then do;
_MAXP = _P1;
_IY = 2;
end;
I_cible = REGDRF[_IY];
U_cible = REGDRU[_IY];
label SCOREGLOB2="Score modle global 2";
SCOREGLOB2=P_cibleINDSOLD4M200E;
WARN_GLOB=_WARN_;
%mend;
*************************************;
*************************************;
*************************************;
*************************************;
*************************************;
***** end scoring code for regression;
*************************************;
*************************************;
*************************************;
*************************************;
*************************************;
data newtableB_scoree_&m1 (keep=numcaf matricul nordallc scoreglob2 scoressrsa2 scoresit2 scoresitpro2 scorelog2 SCOREMAX2
warn_glob warn_rsa warn_sit warn_sitpro warn_log
MATRICUL NORDALLC NUMCAF MS NADRESS18_quant OPT_MACT12 OPT_NMODLOY18 OPT_MACT12 FGRESTRI18_quant
OPT_FGORINET12 OPT_FGORIREC18
OPT_MOIFGRESAN MOICONTVER_quant
NBWEB18_quant OPT_MOIONTAVU MOIPIE_NOTINT_quant
MOIPIE_NPAI_quant OPT_MOIPIE_DSIT
OPT_MOIPIE_MAIL OPT_NBPIE_DSIT18 OPT_NBPIE_MAIL18
ABANEU agecon_quant ageresp_quant MOINSCDO_quant
MTPAJCAV_quant NBM_ODMS_quant RUC_RED_quant STATUETU TITUBANC
topen19 topen19 TOPENF1218_P tut_P TXEFF_P TYPAAH
COMPANTRIM SEQACR SEQFAM );
set newtableB_scoree_&m1 ;
%scoreglob2;
run;
data WARNING;
set newtableB_scoree_&m1;
where warn_glob ne "";
run;
proc datasets lib=work nolist; delete FINAL FINAL2; quit; run;
/* MODIF CNEDI POUR INTEGRATION NOUVEAU MODELE DANS FLUX EXISTANT */
/* modif 08/2011 baseloc en work*/
/* tri par scoremax et renomage des score comme les anciens utiliss dans l'application affinage de al politique de contrle*/
proc sort data=newtableB_scoree_&m1 ( rename=(scoreglob2=scorglob));
by descending SCORGLOB ;
run;
/*Liste des variables conserver */
/*Liste des variables modle (sept2014) */
%let frescore2=NUMCAF DTREFFRE DTCRE MATRICUL NORDALLC ABANEU AGECON_quant AGERESP_quant COMPANTRIM
FGRESTRI18_quant MOICONTVER_quant MOINSCDO_quant
MOIPIE_NOTINT_quant MOIPIE_NPAI_quant MTPAJCAV_quant NADRESS18_quant NBM_ODMS_quant
NBWEB18_quant OPT_FGORINET12 OPT_FGORIREC18
OPT_MACT12 OPT_MOIFGRESAN
OPT_MOIONTAVU OPT_MOIPIE_DSIT OPT_MOIPIE_MAIL
OPT_NBPIE_DSIT18
OPT_NBPIE_MAIL18 OPT_NMODLOY18 RUC_RED_quant SEQACR SEQFAM STATUETU TITUBANC
TOPEN19 TOPENF1218_P TUT_P TXEFF_P TYPAAH warn_glob;
/*Sortie et azrchivage des tables FRESCORE et FRE du mois de rfrence du scoring*/
options compress = yes ;
data work.FRESCOR2&m1. (keep= &frescore2.);
set work.newtableB_scoree_&m1 ;
DTREFFRE = &mvDTREFFRE. ;
DTCRE = date() ;
run;
%mend;
%DM_DE;
# Algorithme de scoring de la CAF
Nous présentons ici le code source envoyé par la CAF des deux versions de l'algorithme descoring utilisées respectivement entre 2010 et 2014 puis 2014 et 2018.
Nous présentons ici le code source envoyé par la CAF des deux versions de l'algorithme descoring utilisées respectivement entre 2010 et 2014 puis 2014 et 2018 ainsi que le fichier utilisé pour simuler les scores de risques tels que présentés dans [cet article](https://www.laquadrature.net/2023/11/27/notation-des-allocataires-lindecence-des-pratiques-de-la-caf-desormais-indeniable).
Le fichier « scoring_simul » est celui que nous avons utilisé pour simuler les scores de risques tels que présentés dans [cet article](https://www.laquadrature.net/2023/11/27/notation-des-allocataires-lindecence-des-pratiques-de-la-caf-desormais-indeniable).
Nous présentons ici les détails méthodologiques relatifs à [notre article](https://www.laquadrature.net/2023/11/27/notation-des-allocataires-lindecence-des-pratiques-de-la-caf-desormais-indeniable) présentant le code source de l'algorithme de notation des allocataires de la CAF. Le code source tel que communiqué par la CAF est disponible [ici]() pour la version 2010 et [ici]() pour la version 2014.
L'annexe méthodologique présentant les simulations est disponible.
## Des documents acquis de haute lutte
Cet article se base sur le code source de deux versions de l'algorithme. La première a été utilisée entre 2010 et 2014, la seconde entre 2014 et 2018.
L'accès à ces deux versions nous a pris plusieurs mois de travail et d'attente. Elles ont été obtenues via des demandes dites CADA, du nom de la [Commission d'Accès aux Documents Administratifs](https://www.cada.fr/). Après plusieurs demandes sans succès faites auprès de la CAF, nous avons saisi la CADA qui a donné un avis favorable à la communication des deux versions antérieures de l'algorithme. Elle nous a par contre refusé l'accès à la version utilisée actuellement, suivant les demandes de la CAF qui arguait que cela aurait pu aider d'éventuels fraudeurs.
Durant ces longs mois, la CAF aura tout essayé pour nous refuser cet accès. Son principal argument : la communication du code source serait une *« atteinte à la sécurité publique »* car *« en identifiant les critères constituant des facteurs de ciblage, des fraudeurs pourraient organiser et monter des dossiers frauduleux »*.
Selon le même argumentaire, elle a d'ailleurs masqué 6 variables du modèle 2010 et 3 du modèle 2014 au motif que ces variables sont encore utilisées dans le modèle actuel. **Un argumentaire nauséabond à deux titres.** Premièrement, la CAF assume pleinement les logiques policières de ses pratiques de contrôle : pour ses dirigeant·es, les allocataires sont devenu·es des *« risques »* dont il faut se protéger à tout prix.
Deuxièment, comme nous l'expliquions [ici](https://www.laquadrature.net/2022/12/23/notation-des-allocataires-febrile-la-caf-senferme-dans-lopacite/), **cet argument est méprisant et insultant. La CAF croit-elle vraiment que des millions d'allocataires précaires - au coeur du ciblage de l'algorithme - pourraient décider, d’un coup, de sortir de la pauvreté afin d’augmenter leur note et de « flouer » l’algorithme ?**
## Les modèles communiqués et leur entraînement
Les modèles 2010 et 2014 sont des modèles de [régression logistique](https://en.wikipedia.org/wiki/Logistic_regression). Le score attribué par le modèle, compris entre zéro et un, correspond à la probabilité qu'un·e allocataire ait reçu des indus (trop-perçus). Ainsi plus le score est proche de un, plus l'algorithme juge qu'un·e allocataire est suspect·e. Cet algorithme sert ainsi à sélectionner les personnes que la CAF juge indignes de confiance et qui feront l'objet d'un contrôle. Le contrôle est déclenché si la note se dégrade trop, c'est à dire si sa valeur se rapproche de un.
La création de l'algorithme passe par une phase « d'entraînement » lors de laquelle l'algorithme « apprend » à reconnaître des *&*. Cet entraînement se fait sur la base de l'enquête « d’évaluation du paiement à bon droit »[^Collinet]. Cette base comprend plus de 10 000 dossiers ayant fait l'objet d'un contrôle. L'algorithme est entraîné en « comparant » les dossiers pour lesquels des indus ont été détectés et les autres.
Techniquement, l'algorithme est calibré pour cibler le risque d’indus de plus 6 mois et d’un montant supérieur à 600€.
## Etendue des données personnelles traitées pour l'utilisation de ces modèles
Une remarque importante : dans sa stratégie de communication, la CAF cherche à minimiser l'étendue des données personnelles traitées pour l'utilisation de son algorithme. Dans un <a href=https://www.caf.fr/sites/default/files/medias/371/CNAF%20Supports/Controles%20et%20datamining.pdf>Vrai/Faux</a> assez trompeur, la CAF écrit notamment qu'il serait faux de dire que le modèle utilise plus de « 1000 données concernant les allocataires ». Certes les modèles utilisés contiennent une trentaine de variables. Mais deux choses sont sciemment omises par la CAF.
**Premièrement, l'entraînement du modèle - la sélection des variables retenues - utilise une « base d'apprentissage » contenant plus de 1000 données par allocataire**. C'est un directeur de la lutte contre la fraude de la CAF qui <a href=https://www.cairn.info/revue-informations-sociales-2013-4-page-129.htm>l'explique le mieux</a>: *«Après le travail de récupération des informations, les statisticiens chargés de la modélisation disposaient d’environ un millier d’informations par allocataire contrôlé. Pour rechercher des éléments déterminants qui signalent le risque d’apparition d’un indu, la base d’apprentissage contient toutes les données habituelles des fichiers statistiques, à savoir les informations sur la situation familiale de l’allocataire, son activité, ses ressources et ses droits aux prestations légales versées par les Caf »*. Ainsi le modèle nécessite bien plus de variables que la trentaine retenues à la fin : ces dernières sont une sélection de variables choisies en fonction de leur capacité à prédire les indus.
**Deuxièmement, les variables utilisées dans la formule sont construites à partir d'un nombre bien plus grand de variables comme le montre le [code]().** Un exemple parmi d'autres : pour construire la variable « Nb mois en activité sur 12 mois du responsable et du conjoint », la CAF va aller vérifier mois par mois la variable activité pour deux personnes. Sa construction nécessite donc le traitement de 24 variables. Ceci se répète pour l'ensemble des variables prenant en compte un historique.
**Il est donc faux - et trompeur - d'avancer, comme le fait la CAF dans le Vrai/Faux mentionné ci-avant, que le modèle ne nécessite *« qu'une quarantaine [de variables qui] sont utilisées pour calculer le score de risque. »*.**
## Les variables et leur impact
Le modèle 2010 comprend 37 variables, dont 6 ont été masquées par la CAF, et se décline en 5 sous-modèles : risque familial, de logement, professionnel, global et ressources. Le modèle 2014 comprend un unique modèle et 35 variables dont 3 ont été masquées par la CAF.
Vous trouverez ci-dessous une liste des variables communiquées par la CAF pour chaque modèle, classées par grand types. Pour avoir une idée de leur impact sur la note ainsi que les différentes modalités de ces variables, nous publions aussi les documents envoyés par la CAF présentant les « [odds ratios](https://fr.wikipedia.org/wiki/Odds_ratio) ». Il est à noter cependant que certains calculs d'odds ratios par la CAF semblent erronés. Nous corrigerons ceci dès que possible.
- [Variables et modalités modèle 2010](https://www.laquadrature.net/wp-content/uploads/sites/8/2023/11/modele-2010_variables.xls)
- [Variables et modalités modèle 2014](https://www.laquadrature.net/wp-content/uploads/sites/8/2023/11/modele-2014_variables.xls)
Pour la suite on se concentrera sur le modèle 2014 qui est celui à partir duquel a été réalisé l'analyse par profils.
## Méthodologie et limites de nos simulations par profils types
### Limites
Nos profils-types ont été construits à partir du modèle 2014. Nous tenons à être transparent·es sur notre méthodologie et ses limites.
En premier lieu, comme nous l'avons expliqué ci-dessus, 3 variables sont manquantes dans le code source communiqué par la CAF. Les scores calculés ne les prennent donc pas en compte. Deuxièment, pour la construction de ces profils-types, nous avons dû faire des hypothèses fortes pour chacune des variables utilisées par l'algorithme.
Deuxièment, certaines de ces variables sont très techniques et/ou dépendent d'un grand nombre de facteurs et/ou sont dépendantes d'autres variables de l'algorithme. Les variables liées au « Faits générateurs » sont particulièrement difficiles à apprécier.
Enfin, la lecture du code source n'est pas aisée. Certaines variables - comme celle liée à la séquence familiale (séparation récente...) - sont difficilement compréhensibles à partir du seul fichier fourni par la CAF.
**Ainsi, il est fort probable que nous ayons fait des erreurs ou que nos profils-types ne soient pas aussi représentatifs que nous le souhaitions. Les scores calculés pour l'analyse par profils-types sont donc donnés à titre indicatif seulement.**
**Il est toutefois à noter que nos analyses sont cohérentes avec les analyses de Vincent Dubois basées sur des statistiques aggrégées (voir le livre « Contrôler les Assistés » ).** La seule différence porte sur les allocataires de l'AAH, dont Vincent Dubois notait un sous-contrôle. Nous tenons à préciser que ceci est vérifié dans nos analyses, mais seulement pour les personnes bénéficiant de l'AAH annuelle. Ce sont pour celles qui travailllent, et bénéficient donc de l'AAH trimestrielle, que nous obtenus des scores relativement élevés, suggérant un sur-contrôles des personnes à l'AAH trimestrielle.
Vous pouvez nous contacter à algos@laquadrature.net pour toute suggestion/remontée d'erreurs !
### Profils-types
Pour rappel, nos 5 profils sont censés représenter :
1. Une famille « aisée » aux revenus stables et élevés,
2. Une famille « modeste » dont les deux parents gagnent le SMIC,
3. Un parent célibataire gagnant aussi le SMIC,
4. Une famille dont les deux parents sont bénéficiaires des minima sociaux,
5. Une famille dont un des parents est travailleur·se en situation de handicap: pour ce profil, nous simulons le score de la personne bénéficiant de l’AAH trimestrialisée.
Pour chacun de ces profils, nous faisons l'hypothèse que les foyers comprennent deux enfants à charge : un entre 12 et 18 ans et le second ayant plus de 19 ans. Puis, nous faisons des hypothèses concernant les prestations sociales dont bénéficient chacun des profils :
- Les profils 1, 2 et 3 bénéficient uniquement des allocations familiales.
- Dans le profil 4, les deux parents bénéficient du RSA et des allocations familiales
- Dans le profil 5, le parent célibataire bénéficie de l'AAH et des allocations familiales. L'AAH est trimestrialisée puisqu'iel exerce une activité professionnelle.
### Paramètres variant d'un profil à l'autre
Seules 9 variables sont susceptibles de différer entre les profils, les autres étant supposée égales. Nous nous sommes concentré·es sur des différentes variables directement liées aux prestations reçues ou aux revenus. En limitant le nombre de paramètres variant d'un profil à l'autre, nous avons essayé de minimiser notre risque d'erreurs et de nous concentrer sur l'impact des facteurs socio-économiques.
Nous mettons en ligne [ici](https://www.laquadrature.net/wp-content/uploads/sites/8/2023/11/Profils_hypotheses_publi_methodo.xlsx) un fichier détaillant l'ensemble de nos hypothèses, accompagnées d'un commentaire, pour chacun des profils.
Ces variables sont:
- **Nombre faits générateurs (FG) "Ressources Trimestrielles" sur 18 mois** : les FG sont liés aux déclarations de ressources trimestrielles liées aux allocations AAH/RSA/PPA. Pour ces dernières nous nous limitons à 6 FG sur 18 mois, soit les 6 trimestres. Cette hypothèse semble conservatrice (pas d'erreurs, pas de cumul...). Cette variable augmente le score des personnes au RSA/AAH trimestrialisée/PPA.
- **Nombre faits générateurs (FG) d'origine internet sur 12 mois** : on les suppose générés seulement par les déclarations de ressources trimestrielles, égales à 4 donc pour les profils 4 et 5. On exclut donc tout autre fait générateur (naissance, décès, changement activité...) ce qui paraît aussi raisonnable.
- **AAH** : Une variable précisant si l'allocataire bénéficie de l'AAH, de manière annualiseé ou non. Cette variable prend la modalité "AAH trimestrielle" pour le profil 5.
- **Taux d'effort logement** : Proportion des revenus dédiés au logement. Il est supposé supérieur à 35% pour tous les profils sauf le profil 1. Ceci augmente comparativement le score des autres profils.
- **Revenus par unité de consommation** : Vise à mesurer les revenus par membres du foyer. Sa formule exacte est disponible [ici](https://caf.fr/sites/default/files/medias/698/Nous%20connaitre/stats%20communales/explications_stats_externes2021.pdf).
- **Délai depuis ouverture des droits au minimum social**: Cette variable est supérieure à zéro pour le profil 4.
- **Situation familiale sur 18 mois**: La CAF prend en compte la situation familiale (célibataire, marié, pacs...). L'encodage de cette variable est difficilement compréhensible à partir du seul code source fourni par la CAF. Nous nous sommes appuyés sur le fichier présentant les odds ratios envoyé lui aussi par la CAF.
- **Nombre de mois en activité sur 12 mois, responsable du dossier et conjoint**: Cette variable, comprise en 0 et 24, implique que les personnes seules (profil 3) - qui n'auront au maximum que 12 mois d'activité - ou sans travail voient leur score augmenter par rapport aux autres profils. Elle est égale à zéro pour le profil 4, 12 pour les profils 5 et 3 et 24 pour les profils 1 et 2.
- **Délai depuis l'ouverture de droit au minimum social**: délai depuis l'obtention du RSA.
Nous discutons succintement des différents profils-types ci-après.
### Profil 2: Impact des variables directement liées au revenu
L'augmentation du score de suspicion entre le profil 1 (couple aisé) et le profil 2 (couple au smic) est liée aux variables *« Revenus par unité de consommation »* et *« taux d'effort logement »*. Il illustre l'impact des variables financières.
### Profil 3: Impact des variables liées aux familles monoparentales
L'augmentation du score entre le profil 2 (couple au SMIC) et le profil 3 (parent célibataire au SMIC) est liée aux variables *« Nombre de mois en activité sur 12 mois, responsable du dossier et conjoint »* - égal à 12 pour une personne seule contre 24 pour un couple - et le *« Revenus par unité de consommation »* qui diminue le montant total des revenus du foyer étant plus faible pour le profil 3. Il semble illustrer le ciblage des familles monoparentale.
Une variable non prise en compte est celle liée au délai depuis la séparation. Si la séparation a eu lieu dans les 18 derniers mois, cela devrait augmenter encore le score de suspicion du profil 3.
### Profil 4: Impact des variables liées à l'AAH
Le profil 4 correspond à un allocataire bénéficiant de l'AAH trimestrialisée marié·e. La différence avec le profil 2 (couple au SMIC) est donc le fait de bénéficier de l'AAH. L'augmentation comparative du score entre les deux profils s'explique:
- Par la variable « AAH » qui prend une valeur « AAH trimestrialisée »,
- Par les variables « Nombre faits générateurs (FG) "Ressources Trimestrielles" sur 18 mois » et « Nombre faits générateurs (FG) d'origine internet sur 12 mois ». On suppose ici que la première est fixée à 6, l'allocataire devant déclarer ses ressources trimestriellement et 4 pour la seconde par effet mécanique en supposant que ces déclarations sont faites sur internet.
### Profil 5: Impact des variables liées au RSA
Le profil 5 correspond à un couple au RSA depuis longtemps. Il illustre le ciblage lié aux revenus et celui lié aux minima sociaux. L'augmentation comparative du score entre ce profil et le profil 2 (couple au SMIC) s'explique:
- Par la variable « Délai depuis l'ouverture de droit au minimum social »,
- Par les variables « Nombre faits générateurs (FG) "Ressources Trimestrielles" sur 18 mois » et « Nombre faits générateurs (FG) d'origine internet sur 12 mois ». Comme pour le profil 4, on suppose ici que la première est fixée à 6, l'allocataire devant déclarer ses ressources trimestriellement et 4 pour la seconde par effet mécanique en supposant que ces déclarations sont faites sur internet.
- Par la variable « Revenus par unité de consommation » qui est plus faible pour ce profil que dans le cas où les parents gagnent le SMIC.
[^Collinet]: Pour des détails techniques sur l’algorithme et son entraînement voir l’article de Pierre Collinet « Le datamining dans les caf : une réalité, des perspectives », écrit en 2013 et disponible [ici](https://www.cairn.info/revue-informations-sociales-2013-4-page-129.htm). Il y explique notamment que l’entraînement de l’algorithme mobilise une base contenant plus de 1000 informations par allocataire. Le modèle final, après entraînement et sélection des variables les plus « intéressantes », se base sur quelques dizaines de variables. Y est aussi expliqué le fait que l’algorithme est entraîné pour détecter les indus et non les cas de fraude.
Auteurice: La Quadrature du Net
Date: 20230921
%% Cell type:markdown id:1eb8d5b3-d054-46ee-b68c-656c220bb869 tags:
# Analyse algorithme de scoring de la CAF
Ce notebook présente les analyses réalisées dans le cadre de l'article portant sur l'analyse du score de risque de publié par la CAF.
Nous avons d'abord implémenté le code fourni par la CAF en R, puis fait différentes hypothèses pour simuler des profils-types.
Auteurice: La Quadrature du Net
Date: 20230921
%% Cell type:markdown id:fa7778ad-5a7d-42ac-b902-e7bcf33126c9 tags:
## Point méthodologique et limites
L'algorithme de la CAF calcule un « score de suspicion » pour chaque allocataire selon différentes variables (revenus, situations familiale, situation professionnelle, santé...). Ce « score de suspicion » représente la probabilité estimée q'un·e allocataire ait fraudé·e. Les personnes avec le « score de suspicion » le plus élevé sont automatiquement contrôlées.
Pour construire les scores de suspicion, nous devons faire de nombreuses hypothèses dont on ne peut s'assurer qu'elles soient toutes cohérentes ou juste. Les variables liées au « Faits générateurs » sont particulièrement difficiles à apprécier.
Les scores calculés pour l'analyse par profils-types sont donc donnés à titre indicatif seulement.
Il est à noter que nos analyses sont cohérentes avec les analyses de Vincent Dubois basées sur des statistiques aggrégées (Voir le livre « Contrôler les Assistés » ). La seule différence porte sur les allocataires de l'AAH, dont Vincent Dubois notait un sous-contrôle. Nous tenons à préciser que ceci est vérifié dans nos analyses, mais seulement pour les personnes bénéficiant de l'AAH annuelle. Ce sont pour celles qui travailllent, et bénéficient donc de l'AAH trimestrielle, que nous obtenus des scores relativement élevés, suggérant un sur-contrôles des personnes à l'AAH trimestrielle.
Nous publions ici l'ensemble de nos calculs et hypothèses. Contactez nous à algos@laquadrature.net si vous trouvez une erreur ou avez des remarques.
%% Cell type:code id:ceddbf70-ceda-4f73-9fa7-77c09cbfd5ef tags:
``` R
# Compute score
score <- function(
AAH, # Trimestrielle ou annuelle ou rien
NBM_ODMS_quant, # Nb mois depuis ouverture des droits aux minima sociaux
OPT_MACT12, # Nb mois en activité réponsable dossier + conjoint sur 24 derniers mois
RUC_RED_quant, # Revenus par unité de consommation
TXEFF_P, # Taux d'effort logement
# Vie pro
SEQACR, # Evolution activité pro
COMPANTRIM, # Evolution revenus
# Vie familiale
SEQFAM,
TOPENF1218 = 1, # 1 enfant 12-18
agecon_quant = 0, # Pas de conjoint de 60 ans
ageresp_quant = 1, # Responsable dossier moins de 33 ans
topen19 =1, # 1 enfant de plus de 19 ans
# Déclaration de situation
OPT_MOIPIE_DSIT = 1, # Plus de 5 mois depuis déclaration de situation
OPT_NBPIE_DSIT18 = 0, # Pas de piece DSIT depuis 18 mois
# Mails
OPT_MOIPIE_MAIL = 2, # Plus de 5 mois depuis mail
OPT_NBPIE_MAIL18 = 1, # Plus de deux mails sur 18 mois
# Déménagement
OPT_NMODLOY18 = 0, # Pas de modif de loyer
NADRESS18_quant = 0, # Pas de chgt d'adresse
# FG
OPT_FGORINET12, # FG origine internet
FGRESTRI18_quant, # FG ressources trimestrielles
OPT_FGORIREC18 = 0, # Aucun FG PGME sur 18 mois
OPT_MOIFGRESAN = 2, # Aucun FG RESANN sur 5 mois
# Autres
ABANEU =0, # Pas d'abattement
MOICONTVER_quant = 0, # Jamais eu de contrôle
MOINSCDO_quant = 2, # Affiliation > 49 mois
MOIPIE_NOTINT_quant = 1, # Pas de piece information interne
MOIPIE_NPAI_quant = 0, # Pas de piece NPAI
MTPAJCAV_quant = 0, # Pas de PAJE
NBWEB18_quant = 2, # 12-34 soit une connection par mois
OPT_MOIONTAVU = 2, # Pas de contact accueil les deux derniers mois
TITUBANC = 0, # Pas d'incohérence
tut_P =0 # Pas de tutelle
){
lp0=0
# AAH
if (AAH == 0) { # Aucune
lp0 = lp0 - 0.21025373930299 * 1
} else if (AAH == 1) { # Trimestrielle
lp0 = lp0 + 0.72818206088848 * 1
} else if (AAH ==2 ){ # Annuelle
lp0 = lp0 - 0.21025373930299 * -1
lp0 = lp0 + 0.72818206088848 * -1
}
# COMPANTRIM (évolution des revenus, responsable et conjoint)
if (COMPANTRIM == 0 ) { # Autres
lp0 = lp0 + 0.2213879461932 * 1
lp0 = lp0 - 0.23758864170547 * 0
lp0 = lp0 + 0.10014517695226 * 0
lp0 = lp0 + 0.28214016541774 * 0
} else if (COMPANTRIM == 1 ){ # Stable sans activité pro (responsable et conjoint)
lp0 = lp0 + 0.2213879461932 * -1
lp0 = lp0 - 0.23758864170547 * -1
lp0 = lp0 + 0.10014517695226 * -1
lp0 = lp0 + 0.28214016541774 * -1
} else if (COMPANTRIM == 2 ){ # Baisse
lp0 = lp0 + 0.2213879461932 * 0
lp0 = lp0 - 0.23758864170547 * 1
lp0 = lp0 + 0.10014517695226 * 0
lp0 = lp0 + 0.28214016541774 * 0
} else if (COMPANTRIM == 3 ){ # Hausse
lp0 = lp0 + 0.2213879461932 * 0
lp0 = lp0 - 0.23758864170547 * 0
lp0 = lp0 + 0.10014517695226 * 1
lp0 = lp0 + 0.28214016541774 * 0
} else if (COMPANTRIM == 4 ){ # Stable avec activité pro (responsable et conjoint)
lp0 = lp0 + 0.2213879461932 * 0
lp0 = lp0 - 0.23758864170547 * 0
lp0 = lp0 + 0.10014517695226 * 0
lp0 = lp0 + 0.28214016541774 * 1
}
# NBODMS (mois depuis ouverture minima sociaux) -> vérifier odds ratios donnés par la CAF
if (NBM_ODMS_quant == 0) { # Pas de minima sociaux
lp0 = lp0 - 0.39791200043493 * 1
lp0 = lp0 - 0.20817360952199 * 0
lp0 = lp0 + 0.32033067809115 * 0
} else if ( NBM_ODMS_quant == 1) { # 1 à 12 mois
lp0 = lp0 - 0.39791200043493 * 0
lp0 = lp0 - 0.20817360952199 * 1
lp0 = lp0 + 0.32033067809115 * 0
} else if ( NBM_ODMS_quant == 2) { # 13 à 32 mois
lp0 = lp0 - 0.39791200043493 * 0
lp0 = lp0 - 0.20817360952199 * 0
lp0 = lp0 + 0.32033067809115 * 1
} else if ( NBM_ODMS_quant == 3) { # 13 à plus
lp0 = lp0 - 0.39791200043493 * -1
lp0 = lp0 - 0.20817360952199 * -1
lp0 = lp0 + 0.32033067809115 * -1
}
# OPT_MACT12: Nb mois en activité sur 12 mois -> Checker odds donnés par la CAF
if (OPT_MACT12 == 0) { # Pas d'activité
lp0 = lp0 + 0.27730925279732 * 1
lp0 = lp0 + 0.32522331141171 * 0
} else if (OPT_MACT12 ==1 ){ # 1 à 14 mois
lp0 = lp0 + 0.27730925279732 * 0
lp0 = lp0 + 0.32522331141171 * 1
} else if (OPT_MACT12 == 2 ){ # 14 mois et plus
lp0 = lp0 + 0.27730925279732 * -1
lp0 = lp0 + 0.32522331141171 * -1
}
# RUC_RED_quant: Revenus par unité de consommation
if (RUC_RED_quant == 0) { # Inférieur à 577
lp0 = lp0 + 0.33484019169728 * 1
lp0 = lp0 - 0.79175797044132 * 0
lp0 = lp0 + 0.43094626466292 * 0
} else if (RUC_RED_quant == 1) { # 577-942
lp0 = lp0 + 0.33484019169728 * 0
lp0 = lp0 - 0.79175797044132 * 0
lp0 = lp0 + 0.43094626466292 * 1
} else if (RUC_RED_quant == 2) { # 942-1483
lp0 = lp0 + 0.33484019169728 * -1
lp0 = lp0 - 0.79175797044132 * -1
lp0 = lp0 + 0.43094626466292 * -1
} else { # > 1483
lp0 = lp0 + 0.33484019169728 * 0
lp0 = lp0 - 0.79175797044132 * 1
lp0 = lp0 + 0.43094626466292 * 0
}
# TXEFF_P : Tx effort logement après aide
if ( TXEFF_P == 0) { # Inférieur à 35%
lp0 = lp0 -0.09635968487988 * 1
} else {
lp0 = lp0 -0.09635968487988 * -1
}
# FGRESTRI18_quant Faits générateurs Ressources trimestrielles sur 18 mois (Defaut:0)
if (FGRESTRI18_quant==0) { # Aucun
lp0 = lp0 - 0.25528218660984 * 1;
} else if (FGRESTRI18_quant==1 ){ # 1 à 6
lp0 = lp0 - 0.03407843771333 * 1;
} else if (FGRESTRI18_quant==2 ){ # 7 à 11
lp0 = lp0 - 0.25528218660984 * -1;
lp0 = lp0 - 0.03407843771333 * -1;
lp0 = lp0 + 0.24828745194934 * -1;
} else if (FGRESTRI18_quant==3 ){ # 11 et plus
lp0 = lp0 + 0.24828745194934 * 1;
}
### OPT_FGORINET12 (Defaut:0) Nb Faits Générateurs "information source de la liquidation, d'origine Internet" sur 12 mois
if (OPT_FGORINET12 == 0) { # Aucun
lp0 = lp0 - 0.16773363709676 * 1
lp0 = lp0 + 0.01415184255654 * 0
lp0 = lp0 - 0.13428969940581 * 0
} else if (OPT_FGORINET12 == 1) { # 1 à 2
lp0 = lp0 - 0.16773363709676 * 0
lp0 = lp0 + 0.01415184255654 * 1
lp0 = lp0 - 0.13428969940581 * 0
} else if (OPT_FGORINET12 == 2) { # 3 à 5
lp0 = lp0 - 0.16773363709676 * 0
lp0 = lp0 + 0.01415184255654 * 0
lp0 = lp0 - 0.13428969940581 * 1
} else if (OPT_FGORINET12 == 3) { # + 5
lp0 = lp0 - 0.16773363709676 * -1
lp0 = lp0 + 0.01415184255654 * -1
lp0 = lp0 - 0.13428969940581 * -1
}
### SEQACR (Defaut:0) Changement de situation professionnelles (Pas traitée entièrement)
# Cas ACT_X_X -> A creuser pour le reste
if (SEQACR == 0){# Reste en activité a priori, ou pas de chgts
lp0 = lp0 + 0.11009895761839 * 0
lp0 = lp0 + 0.01494576600753 * 1
lp0 = lp0 - 0.35411923214215 * 0
} else if (SEQACR == 1) { # Passage de en activité au chômage a priori
lp0 = lp0 + 0.11009895761839 * 0
lp0 = lp0 + 0.01494576600753 * 0
lp0 = lp0 - 0.35411923214215 * 1
} else if (SEQACR == 2) { # Reste en inactivité pro
lp0 = lp0 + 0.11009895761839 * -1
lp0 = lp0 + 0.01494576600753 * -1
lp0 = lp0 - 0.35411923214215 * -1
} else { # Le reste
lp0 = lp0 + 0.11009895761839 * 1
lp0 = lp0 + 0.01494576600753 * 0
lp0 = lp0 - 0.35411923214215 * 0
}
### SEQFAM (Defaut:0) Sequence vie familiale
# A vérifier, construit via la table des odds-ratio,
# pas possible de comprendre les variables dans le code
if (SEQFAM == 0 ) { # Autres
lp0 = lp0 + 0.02688244090902 * 1
lp0 = lp0 + 0.66925439399747 * 0
lp0 = lp0 - 0.63687561103914 * 0
lp0 = lp0 - 0.49280197200267 * 0
lp0 = lp0 + 0.125581957456 * 0
} else if (SEQFAM == 1 ) { # Pacs sans évolution
lp0 = lp0 + 0.02688244090902 * 0
lp0 = lp0 + 0.66925439399747 * 0
lp0 = lp0 - 0.63687561103914 * 1
lp0 = lp0 - 0.49280197200267 * 0
lp0 = lp0 + 0.125581957456 * 0
} else if (SEQFAM == 2 ) { # Veuf sans évolution
lp0 = lp0 + 0.02688244090902 * 0
lp0 = lp0 + 0.66925439399747 * 0
lp0 = lp0 - 0.63687561103914 * 0
lp0 = lp0 - 0.49280197200267 * 1
lp0 = lp0 + 0.125581957456 * 0
} else if (SEQFAM == 3 ) { # Veuf divorcé séparé avec une évolution
lp0 = lp0 + 0.02688244090902 * 0
lp0 = lp0 + 0.66925439399747 * 1
lp0 = lp0 - 0.63687561103914 * 0
lp0 = lp0 - 0.49280197200267 * 0
lp0 = lp0 + 0.125581957456 * 0
} else if (SEQFAM == 4 ) { # Marié-vie maritale sans évolution
lp0 = lp0 + 0.02688244090902 * 0
lp0 = lp0 + 0.66925439399747 * 0
lp0 = lp0 - 0.63687561103914 * 0
lp0 = lp0 - 0.49280197200267 * 0
lp0 = lp0 + 0.125581957456 * 1
} else if (SEQFAM == 5 ) { # 2 changements d'évolution
lp0 = lp0 + 0.02688244090902 * -1
lp0 = lp0 + 0.66925439399747 * -1
lp0 = lp0 - 0.63687561103914 * -1
lp0 = lp0 - 0.49280197200267 * -1
lp0 = lp0 + 0.125581957456 * -1
}
############### Les suivantes sont similaires d'un profil type à l'autre #################
# ABANEU
if (ABANEU == 1) {
lp0 = lp0 + 0.23232764382303 * 1
} else {
lp0 = lp0 + 0.23232764382303 * -1
}
### MOICONTVER_quant Nb mois depuis dernier contrôle/vérif (Default:0)
if (MOICONTVER_quant == 0) { # Pas de contrôle
lp0 = lp0 -0.21768333198141 * 0
lp0 = lp0 +0.09656226810839 * 0
lp0 = lp0 +0.3753744654792 * 0
lp0 = lp0 -0.21053899338984 * 0
} else if (MOICONTVER_quant == 1) { # 1 à 3
lp0 = lp0 - 0.21768333198141 * 1
lp0 = lp0 + 0.09656226810839 * 0
lp0 = lp0 + 0.3753744654792 * 0
lp0 = lp0 - 0.21053899338984 * 0
} else if (MOICONTVER_quant == 2) { # 4 à 6
lp0 = lp0 - 0.21768333198141 * 0
lp0 = lp0 + 0.09656226810839 * 0
lp0 = lp0 + 0.3753744654792 * 1
lp0 = lp0 - 0.21053899338984 * 0
}else if (MOICONTVER_quant == 3) { # 7 à 12
lp0 = lp0 - 0.21768333198141 * 0
lp0 = lp0 + 0.09656226810839 * 0
lp0 = lp0 + 0.3753744654792 * 0
lp0 = lp0 - 0.21053899338984 * 1
} else if (MOICONTVER_quant == 4) { # Plus de 13
lp0 = lp0 - 0.21768333198141 * 0
lp0 = lp0 + 0.09656226810839 * 1
lp0 = lp0 + 0.3753744654792 * 0
lp0 = lp0 - 0.21053899338984 * 0
}
### MOINSCDO_quant (Defaut:0) Nb mois depuis affiliation
if (MOINSCDO_quant == 0 ) { # 0 à 11
lp0 = lp0 - 0.37223848913268 * 1
lp0 = lp0 + 0.22711099427676 * 0
} else if (MOINSCDO_quant == 1 ) { # 12 à 48
lp0 = lp0 - 0.37223848913268 * 0
lp0 = lp0 + 0.22711099427676 * 1
} else if (MOINSCDO_quant == 2 ) { # Plus de 48
lp0 = lp0 - 0.37223848913268 * -1
lp0 = lp0 + 0.22711099427676 * -1
}
### MOIPIE_NOTINT_quant (Defaut:0) Nb mois depuis l'inscription d'une information interne
if (MOIPIE_NOTINT_quant == 0 ){ # 5 à 18
lp0 = lp0 + 0.4409911195616 * -1
} else { # Autre
lp0 = lp0 + 0.4409911195616 * 1
}
### MOIPIE_NPAI_quant (Defaut:0) Nb mois despuis la réception d'une pièce Npai
if (MOIPIE_NPAI_quant == 0 ) { # Aucune ou plus de 18
lp0 = lp0 + 0.10801749528109 * 1
lp0 = lp0 + 0.30748094150248 * 0
} else if (MOIPIE_NPAI_quant == 1 ) { # 1 à 4
lp0 = lp0 + 0.10801749528109 * -1
lp0 = lp0 + 0.30748094150248 * -1
} else if (MOIPIE_NPAI_quant == 2 ) { # 5 à 18
lp0 = lp0 + 0.10801749528109 * 0
lp0 = lp0 + 0.30748094150248 * 1
}
### MTPAJCAV_quant (Defaut:0) Montant PAJE Complément d'Activité versable
if (MTPAJCAV_quant == 0 ) { # Aucune
lp0 = lp0 + 0.19975598506804 * 1
lp0 = lp0 + 0.02474201858734 * 0
} else if (MTPAJCAV_quant == 1 ) { # 1 à 360
lp0 = lp0 + 0.19975598506804 * 0
lp0 = lp0 + 0.02474201858734 * 1
} else if (MTPAJCAV_quant == 2 ) { # 360 et plus
lp0 = lp0 + 0.19975598506804 * -1
lp0 = lp0 + 0.02474201858734 * -1
}
### NADRESS18_quant (Defaut:0) Nb changement d'adresse sur 18 derniers mois
if (NADRESS18_quant == 0 ){ # Aucune
lp0 = lp0 + 0.32426185988357 * 1
lp0 = lp0 - 0.45225170547949 * 0
} else if (NADRESS18_quant == 1 ){ # 1 à 3
lp0 = lp0 + 0.32426185988357 * 0
lp0 = lp0 - 0.45225170547949 * 1
} else if (NADRESS18_quant == 2 ){ # 4 et plus
lp0 = lp0 + 0.32426185988357 * -1
lp0 = lp0 - 0.45225170547949 * -1
}
### NBWEB18_quant (Defaut:0) Nb jours avec connection Web / 18 derniers mois
if (NBWEB18_quant == 0 ) { # 0 à 3
lp0 = lp0 + 0.02477883999277 * 1
lp0 = lp0 - 0.11336860212259 * 0
lp0 = lp0 - 0.05326803815191 * 0
} else if (NBWEB18_quant == 1 ) { # 4 à 11
lp0 = lp0 + 0.02477883999277 * -1
lp0 = lp0 - 0.11336860212259 * -1
lp0 = lp0 - 0.05326803815191 * -1
} else if (NBWEB18_quant == 2 ) { # 12 à 33
lp0 = lp0 + 0.02477883999277 * 0
lp0 = lp0 - 0.11336860212259 * 1
lp0 = lp0 - 0.05326803815191 * 0
} else if (NBWEB18_quant == 3 ) { # 34 et plus
lp0 = lp0 + 0.02477883999277 * 0
lp0 = lp0 - 0.11336860212259 * 0
lp0 = lp0 - 0.05326803815191 * 1
}
### OPT_FGORIREC18 (Defaut:0) (Binning 4) Nb FG d'origine PGME recupt sur 18 mois
if (OPT_FGORIREC18 == 0 ) { # Aucun
lp0 = lp0 - 0.15511757943741 * 1
} else { # Au moins 1
lp0 = lp0 - 0.15511757943741 * -1
}
### OPT_MOIFGRESAN (Defaut:1) (Binning 3) Nb de mois depuis le dernier fait générateur RESANN
if (OPT_MOIFGRESAN == 0 ) { # Aucun
lp0 = lp0 - 0.81202850635466 * 1
lp0 = lp0 + 0.61923386123076 * 0
} else if (OPT_MOIFGRESAN == 1 ) { # 1 à 4
lp0 = lp0 - 0.81202850635466 * 0
lp0 = lp0 + 0.61923386123076 * 1
} else if (OPT_MOIFGRESAN == 2 ) { # Plus de 4
lp0 = lp0 - 0.81202850635466 * -1
lp0 = lp0 + 0.61923386123076 * -1
}
### OPT_MOIONTAVU (Defaut:0) (Binning 3) Nb de mois depuis contact accueil
if (OPT_MOIONTAVU == 0 ) { # 0
lp0 = lp0 + 0.13627815941635 * 1
lp0 = lp0 - 0.04374801754763 * 0
} else if (OPT_MOIONTAVU == 1 ) { # 1
lp0 = lp0 + 0.13627815941635 * 0
lp0 = lp0 - 0.04374801754763 * 1
} else if (OPT_MOIONTAVU == 2 ) { # Plus de 2 mois
lp0 = lp0 + 0.13627815941635 * -1
lp0 = lp0 - 0.04374801754763 * -1
}
### OPT_MOIPIE_DSIT Nb de mois depuis début DSIT
if (OPT_MOIPIE_DSIT == 0) { # Moins de 5
lp0 = lp0 - 0.3597481037668 *1
} else if (OPT_MOIPIE_DSIT ==1) { # Plus de 5
lp0 = lp0 - 0.3597481037668 *0
}
### MOIPIE_MAIL (Defaut:0)
if (OPT_MOIPIE_MAIL == 0){ # Moins de 2
lp0 = lp0 - 0.15537483693343 * 1
lp0 = lp0 + 0.37315035245438 * 0
} else if (OPT_MOIPIE_MAIL == 1){ # 2 à 4
lp0 = lp0 - 0.15537483693343 * 0
lp0 = lp0 + 0.37315035245438 * 1
} else if (OPT_MOIPIE_MAIL == 2){ # Plus de 4
lp0 = lp0 - 0.15537483693343 * -1
lp0 = lp0 + 0.37315035245438 * -1
}
### OPT_NBPIE_DSIT18 (Defaut:0) Nb de pieces DSIT 18 mois
if (OPT_NBPIE_DSIT18 == 0 ) { # Aucune
lp0 = lp0 + 0.29525355588199 * 1
} else if (OPT_NBPIE_DSIT18 == 1){ # Au moins une
lp0 = lp0 + 0.29525355588199 * -1
}
### OPT_NBPIE_MAIL18 (Defaut:0) Nb de mails 18 mois
if (OPT_NBPIE_MAIL18 == 0 ) { # Moins de 2
lp0 = lp0 + 0.13623828752591 * 1
} else {
lp0 = lp0 + 0.13623828752591 * -1
}
### OPT_NMODLOY18 (Defaut:0) Nb modification Code postal / 18 mois
if (OPT_NMODLOY18 == 0 ) {# Aucun
lp0 = lp0 - 0.54676525776417 * 1
lp0 = lp0 - 0.31601088054791 * 0
} else if (OPT_NMODLOY18 == 1 ){ # Entre 1 et 4
lp0 = lp0 - 0.54676525776417 * 0
lp0 = lp0 - 0.31601088054791 * 1
} else if (OPT_NMODLOY18 == 2 ) { # Plus de 4
lp0 = lp0 - 0.54676525776417 * -1
lp0 = lp0 - 0.31601088054791 * -1
}
### TITUBANC (Defaut:0) Incohérences RIB
if (TITUBANC == 0 ) { # Pas d'incohérences
lp0 = lp0 - 0.2042472331848 * 1
lp0 = lp0 - 0.30962992811117 * 0
} else if (TITUBANC ==1 ) { # ?
lp0 = lp0 - 0.2042472331848 * 0
lp0 = lp0 - 0.30962992811117 * 1
} else if (TITUBANC == 2 ) { # IncohérencesA
lp0 = lp0 - 0.2042472331848 * -1
lp0 = lp0 - 0.30962992811117 * -1
}
### TOPENF12TOPENF121818 (Defaut:0) Enfants de 12 à 18 ans
if (TOPENF1218 == 0 ) { # Pas d'enfants 12-18
lp0 = lp0 -0.08779929863942 * 1
} else { # Au moins un enfant entre 12-118
lp0 = lp0 -0.08779929863942 * -1
}
### agecon_quant Age du conjoint > 60
if (agecon_quant == 0 ) { # Autre
lp0 = lp0 + 0.27722626019663 * - 1
} else { # Age conjoint supérieur à 60
lp0 = lp0 + 0.27722626019663 * + 1
}
### ageresp_quant Age responsable dossier inférieur à 33
if (ageresp_quant == 0 ) { # Autres
lp0 = lp0 + 0.11334632521637 * -1
} else { # Inféfieur à 33
lp0 = lp0 + 0.11334632521637 * 1
}
### topen19 Enfants de plus de 19 ans
if (topen19 == 1 ) {
lp0 = lp0 + 0.89385926213357
}
### tut_P Présence tutelle
if (tut_P == 0 ) { # Tutelle
lp0 = lp0 + 0.60450601197118 * 1
} else { # Pas de tutelle
lp0 = lp0 + 0.60450601197118 *-1
}
# Add constant
lp0 = -1.73654727320913 + lp0
# Compute probabilité
score = 1/(1+exp(-lp0))
score
}
```
%% Cell type:code id:6126c03f-2f84-4d2a-b44a-38ac3d31a74a tags:
``` R
print("Famille riche (fam_riche)")
fam_riche <- score(
# AAH et MS
AAH = 0, # pas de AAH
NBM_ODMS_quant=0, # pas de ms
# Vie pro
SEQACR = 0, # En activité, sans changements
OPT_MACT12=2,# Travail stable, couple
RUC_RED_quant=3, # Hauts revenus
COMPANTRIM=4, # Stable
# Vie familiale
SEQFAM = 4, # Mariés stable
# Habitat
TXEFF_P= 0, # < 35
# FG
FGRESTRI18_quant = 0, # Aucun FG ressources trimestrielles
OPT_FGORINET12 = 0, # Aucun FG internet sur 12 mois
)
fam_riche
```
%% Output
[1] "Famille riche (fam_riche)"
0.0827470712641664
0.0827470712641664
%% Cell type:code id:d958e7c0-4b6f-4719-be0e-a65866061d74 tags:
``` R
print("Famille smic")
fam_smic <- score(
# AAH et MS
AAH = 0, # pas de AAH
NBM_ODMS_quant=0, # pas de ms
# Vie pro
SEQACR = 0, # En activité, sans changements
OPT_MACT12=2,# Travail stable, couple
RUC_RED_quant=1, # Revenus moyens (SMIC)
COMPANTRIM = 4, # Stable
# Vie familiale
SEQFAM = 4, # Mariés stable
# Habitat
TXEFF_P= 1, # > 35
OPT_NMODLOY18 = 0, # Pas de modifs de loyers
NADRESS18_quant = 0, # Pas de chgt d'adresse
# FG
FGRESTRI18_quant = 0, # Aucun FG ressources trimestrielles
OPT_FGORINET12 = 0, # Aucun FG internet
# Autres
ABANEU=0, # Pas d'abattement
MOICONTVER_quant = 0, # Jamais eu de contrôle
MOINSCDO_quant = 2, # Vieux à l'affiliation > 49 mois
MOIPIE_NOTINT_quant = 1, # Pas de piece information interne
MOIPIE_NPAI_quant = 0, # Pas de piece NPAI
MTPAJCAV_quant = 0, # Pas de PAJE
NBWEB18_quant = 0, # 12-34 soit une connection par mois
OPT_MOIONTAVU = 2, # Pas de contacts accueil en deux mois
TITUBANC = 0, # Pas d'incohérence
tut_P =0 # Pas de tutelles
)
fam_smic
```
%% Output
[1] "Famille smic"
0.299008536092501
0.299008536092501
%% Cell type:code id:91a5ec79-7fae-47b8-9ec7-194f96387f7b tags:
``` R
print("Mère célibataire SMIC")
parent_celib_smic <- score(
# AAH et MS
AAH = 0, # pas de AAH
NBM_ODMS_quant=0, # pas de ms
# Vie pro
SEQACR = 0, # En activité, sans changements
OPT_MACT12=1,# Travail stable, femme seule
RUC_RED_quant=0, # Faibles revenus par UC
COMPANTRIM = 4, # Stable
# Vie familiale
SEQFAM = 0, # Célibataire
# Habitat
TXEFF_P= 1, # > 35
# FG
FGRESTRI18_quant = 0, # Aucun FG ressources trimestrielles
OPT_FGORINET12 = 0, # Aucun FG internet
)
parent_celib_smic
```
%% Output
[1] "Mère célibataire SMIC"
0.436047033156021
0.436047033156021
%% Cell type:code id:6df6d6bb-6ae6-4f38-aef0-7be749a00989 tags:
``` R
print("Famille aux minima sociaux")
fam_ms<- score(
# AAH et MS
AAH = 0, # pas de AAH
NBM_ODMS_quant= 3, # RSA depuis longtemps
# Vie pro
SEQACR = 2, # Au chomage, sans changements
OPT_MACT12=0,# Pas d'activité
RUC_RED_quant=0, # Faibles revenus par UC
COMPANTRIM = 1, # Stable et nul
# Vie familiale
SEQFAM = 4, # Mariés stable
# Habitat
TXEFF_P= 1, # > 35
# FG
FGRESTRI18_quant= 1, # 6 pièces Ressources Trimestrielles
OPT_FGORINET12 = 2, # 4 déclarations RESTRI sur 12 mois
)
fam_ms
```
%% Output
[1] "Famille aux minima sociaux"
0.573900527784925
0.573900527784925
%% Cell type:code id:6d2d2424-8cef-414f-a277-dbc3802194f1 tags:
``` R
print("Couple AAH avec travail")
aah_couple_travail <- score(
# AAH et MS
AAH=1, # Trimestrielle
NBM_ODMS_quant=0,
# Vie pro
SEQACR = 0, # En activité, sans changements
OPT_MACT12=2, # Travail stable, couples
RUC_RED_quant=1, # Revenus moyens
COMPANTRIM = 4, # Stable
# Vie familiale
SEQFAM =4, # Mariés stable
# Habitat
TXEFF_P= 1, # > 35
# FG
FGRESTRI18_quant=1, # 6 pièces Ressources Trimestrielles
OPT_FGORINET12 =2, # 4 déclarations RESTRI sur 12 mois
)
aah_couple_travail
```
%% Output
[1] "Couple AAH avec travail"
0.550554773444217
0.550554773444217
%% Cell type:code id:bde13c50-9994-485e-80ac-97baa849031c tags:
``` R
print("Célibataire AAH tavail")
parent_isolé_aah <- score(
# AAH et MS
AAH = 1, # AAH Trimestrielle
NBM_ODMS_quant=0, # pas de ms
# Vie pro
SEQACR = 0, # En activité, sans changements
OPT_MACT12=1,# Travail stable, femme seule
RUC_RED_quant=0, # Faibles revenus par UC
COMPANTRIM = 4, # Stable
# Vie familiale
SEQFAM = 0, # Célibataire
# Habitat
TXEFF_P= 1, # > 35
# FG
FGRESTRI18_quant = 1, # Aucun FG ressources trimestrielles
OPT_FGORINET12 = 2, # Aucun FG internet
)
parent_isolé_aah
```
%% Output
[1] "Célibataire AAH tavail"
0.718263193667368
0.718263193667368
%% Cell type:code id:b42e6d6f-1eac-4d3c-a1c2-9da0940b1812 tags:
``` R
# Graph
fam_riche
fam_smic
parent_celib_smic
fam_ms
parent_isolé_aah
values <- c(fam_riche, fam_smic,parent_celib_smic, aah_couple_travail, fam_ms) # Create values for barchart
labels <- c(
"Aisée Couple",
"SMIC Couple",
"SMIC Célibataire",
"AAH act. pro (trim.) Couple",
"RSA Couple"
)
par(mar=c(11, 15, 1, 0))
# Barchart with colored bars
barplot(values,
col = "#1b98e0",
names.arg=labels,
las=2,
ylim= c(0,0.7),
#col = rainbow(4)
)
title(
main="Scores simulés (modèle 2014)",
xlab="",
ylab = "Score de suspicion de zéro à 1",
font.lab = 2
)
dev.print(device = png, file = "export.png", width = 600)
```
%% Output
0.0827470712641664
0.0827470712641664
0.299008536092501
0.299008536092501
0.436047033156021
0.436047033156021
0.573900527784925
0.573900527784925
0.718263193667368
0.718263193667368
**png:** 2
\textbf{png:} 2
%% Cell type:code id:fddb8014-ccb2-4509-abea-ced77c76fb7d tags:
``` R
```