1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
|
%let table_Personne_Histo = HISTPERS.VueDogPersonne;
%let table_Garantie_Histo = HISTGARA.VueDogGarantie;
%let table_Evenement_Histo = HISTGARA.VueDogEvenement;
%let table_Garantie = Garantie.VueDogGarantie;
%let table_Evenement = Garantie.VueDogEvenement;
/*****************************************/
/* Liste des adhérents fin décembre 2021 */
/*****************************************/
PROC SQL;
CREATE TABLE GarantieEnCours_Dec2021 AS
SELECT t1.IdTechPersonne,
t1.NumeroPersonne,
t1.EtatGarantie
FROM &table_Garantie_Histo t1
WHERE t1.FlagGarantieEnCours=1 and t1.DateDebutValidite <= mdy(1,1,2022) and t1.DateFinValidite >= mdy(1,1,2022);
QUIT;
DATA GarantieEnCours_Dec2021;
SET GarantieEnCours_Dec2021;
IF EtatGarantie in ("EnRenteViagere","EnServiceDeReversion","Réversion") then DELETE;
RUN;
PROC SORT data=GarantieEnCours_Dec2021 out=PortefeuilleAdherent_Dec2021 nodupkey;
by NumeroPersonne;
run;
PROC SQL;
CREATE TABLE Personne_Dec2021 AS
SELECT t1.NumeroPersonne,
t1.DateSaisieDecesDate
FROM &table_Personne_Histo t1
WHERE t1.DateDebutValidite <= mdy(1,1,2022) and t1.DateFinValidite >= mdy(1,1,2022);
QUIT;
PROC SQL;
CREATE TABLE PortefeuilleAdherent_Dec2021 AS
SELECT t1.*,
t2.DateSaisieDecesDate
FROM PortefeuilleAdherent_Dec2021 t1 left join Personne_Dec2021 t2 on t1.NumeroPersonne = t2.NumeroPersonne;
QUIT;
DATA PortefeuilleAdherent_Dec2021;
SET PortefeuilleAdherent_Dec2021;
WHERE DateSaisieDecesDate = .;
FlagDejaAdherent_Annee_N = 1;
DROP EtatGarantie DateSaisieDecesDate;
RUN;
PROC DATASETS lib=work nolist;
DELETE GarantieEnCours_Dec2021 Personne_Dec2021;
QUIT;
/***********************************/
/* Nouveaux adhérents Janvier 2022 */
/***********************************/
PROC SQL ;
CREATE TABLE Evenement_Adhesion_Jan2022 AS
SELECT t1.IdTechGarantie,
t1.LibelleCategorieEvenement,
t1.Etat,
t1.DateValidationDate as DateValidationEvenementAdhesion
FROM &table_Evenement_Histo t1
WHERE t1.LibelleCategorieEvenement = 'Adhésion' AND t1.Etat = 'Valide' and t1.DateDebutValidite <= mdy(2,1,2022) and t1.DateFinValidite >= mdy(2,1,2022);
QUIT;
PROC SQL;
CREATE TABLE Garantie_Jan2022 AS
SELECT t1.IdTechPersonne,
t1.NumeroPersonne,
t1.IdTechGarantie,
t1.NumeroComplet,
t1.CodeProduit,
t1.LibelleProduit,
t1.EtatGarantie,
t1.MotifCloture,
t1.DateValidationAdhesionDate,
t1.Source
FROM &table_Garantie_Histo t1
WHERE t1.DateDebutValidite <= mdy(2,1,2022) and t1.DateFinValidite >= mdy(2,1,2022);;
QUIT;
PROC SQL;
CREATE TABLE Garantie_Jan2022 AS
SELECT t1.*,
t2.DateValidationEvenementAdhesion
FROM Garantie_Jan2022 t1 left join Evenement_Adhesion_Jan2022 t2 on t1.IdTechGarantie = t2.IdTechGarantie;
QUIT;
DATA Garantie_Jan2022;
SET Garantie_Jan2022;
IF Source = "AGATE" and CodeProduit ne "CAT" THEN DateValidationAdhesionDate = DateValidationEvenementAdhesion;
RUN;
DATA Garantie_Jan2022;
SET Garantie_Jan2022;
WHERE year(DateValidationAdhesionDate) = 2022;
RUN;
PROC SQL;
CREATE TABLE GarantieNouvAdherent_Jan2022 AS
SELECT t1.*
FROM Garantie_Jan2022 t1
WHERE t1.NumeroPersonne not in (select t2.NumeroPersonne from PortefeuilleAdherent_Dec2021 t2);
QUIT;
PROC SORT DATA=GarantieNouvAdherent_Jan2022 nodupkey out=NouvAdherent_Jan2022;
BY NumeroPersonne;
RUN;
DATA NouvAdherent_Jan2022;
SET NouvAdherent_Jan2022;
length Mois $20.;
Mois = "Janvier";
RUN;
/*****************************************/
/* Liste des adhérents fin janvier 2022 */
/*****************************************/
PROC SQL;
CREATE TABLE GarantieEnCours_Jan2022 AS
SELECT t1.IdTechPersonne,
t1.NumeroPersonne,
t1.EtatGarantie
FROM &table_Garantie_Histo t1
WHERE t1.FlagGarantieEnCours=1 and t1.DateDebutValidite <= mdy(2,1,2022) and t1.DateFinValidite >= mdy(2,1,2022);
QUIT;
DATA GarantieEnCours_Jan2022;
SET GarantieEnCours_Jan2022;
IF EtatGarantie in ("EnRenteViagere","EnServiceDeReversion","Réversion") then DELETE;
RUN;
PROC SORT data=GarantieEnCours_Jan2022 out=PortefeuilleAdherent_Jan2022 nodupkey;
by NumeroPersonne;
run;
PROC SQL;
CREATE TABLE Personne_Jan2022 AS
SELECT t1.NumeroPersonne,
t1.DateSaisieDecesDate
FROM &table_Personne_Histo t1
WHERE t1.DateDebutValidite <= mdy(2,1,2022) and t1.DateFinValidite >= mdy(2,1,2022);
QUIT;
PROC SQL;
CREATE TABLE PortefeuilleAdherent_Jan2022 AS
SELECT t1.*,
t2.DateSaisieDecesDate
FROM PortefeuilleAdherent_Jan2022 t1 left join Personne_Jan2022 t2 on t1.NumeroPersonne = t2.NumeroPersonne;
QUIT;
DATA PortefeuilleAdherent_Jan2022;
SET PortefeuilleAdherent_Jan2022;
WHERE DateSaisieDecesDate = .;
FlagDejaAdherent_Annee_N = 1;
DROP EtatGarantie DateSaisieDecesDate;
RUN;
PROC DATASETS lib=work nolist;
DELETE GarantieEnCours_Jan2022 Personne_Jan2022;
QUIT;
/********************************************/
/* Sortie Nouveaux adhérent en janvier 2022 */
/********************************************/
PROC SQL;
CREATE TABLE GarSortieNouvAdherent_Jan2022 AS
SELECT t1.*
FROM GarantieNouvAdherent_Jan2022 t1
WHERE t1.NumeroPersonne not in (select t3.NumeroPersonne from PortefeuilleAdherent_Jan2022 t3);
QUIT;
PROC SORT DATA=GarSortieNouvAdherent_Jan2022 nodupkey out=SortieNouvAdherent_Jan2022;
BY NumeroPersonne;
RUN;
DATA SortieNouvAdherent_Jan2022;
SET SortieNouvAdherent_Jan2022;
length Mois $20.;
Mois = "Janvier";
RUN;
/***********************************/
/* Nouveaux adhérents Février 2022 */
/***********************************/
PROC SQL ;
CREATE TABLE Evenement_Adhesion_Feb2022 AS
SELECT t1.IdTechGarantie,
t1.LibelleCategorieEvenement,
t1.Etat,
t1.DateValidationDate as DateValidationEvenementAdhesion
FROM &table_Evenement_Histo t1
WHERE t1.LibelleCategorieEvenement = 'Adhésion' AND t1.Etat = 'Valide' and t1.DateDebutValidite <= mdy(3,1,2022) and t1.DateFinValidite >= mdy(3,1,2022);
QUIT;
PROC SQL;
CREATE TABLE Garantie_Feb2022 AS
SELECT t1.IdTechPersonne,
t1.NumeroPersonne,
t1.IdTechGarantie,
t1.NumeroComplet,
t1.CodeProduit,
t1.LibelleProduit,
t1.EtatGarantie,
t1.MotifCloture,
t1.DateValidationAdhesionDate,
t1.Source
FROM &table_Garantie_Histo t1
WHERE t1.DateDebutValidite <= mdy(3,1,2022) and t1.DateFinValidite >= mdy(3,1,2022);;
QUIT;
PROC SQL;
CREATE TABLE Garantie_Feb2022 AS
SELECT t1.*,
t2.DateValidationEvenementAdhesion
FROM Garantie_Feb2022 t1 left join Evenement_Adhesion_Feb2022 t2 on t1.IdTechGarantie = t2.IdTechGarantie;
QUIT;
DATA Garantie_Feb2022;
SET Garantie_Feb2022;
IF Source = "AGATE" and CodeProduit ne "CAT" THEN DateValidationAdhesionDate = DateValidationEvenementAdhesion;
RUN;
DATA Garantie_2022;
SET Garantie_Feb2022;
WHERE year(DateValidationAdhesionDate) = 2022;
RUN;
PROC SQL;
CREATE TABLE Garantie_Feb2022 AS
SELECT t1.*
FROM Garantie_2022 t1
WHERE t1.NumeroComplet not in (select t2.NumeroComplet from Garantie_Jan2022 t2);
QUIT;
PROC SQL;
CREATE TABLE GarantieNouvAdherent_Feb2022 AS
SELECT t1.*
FROM Garantie_Feb2022 t1
WHERE t1.NumeroPersonne not in (select t2.NumeroPersonne from PortefeuilleAdherent_Jan2022 t2) and
t1.NumeroPersonne not in (select t3.NumeroPersonne from PortefeuilleAdherent_Dec2021 t3);
QUIT;
PROC SORT DATA=GarantieNouvAdherent_Feb2022 nodupkey out=NouvAdherent_Feb2022;
BY NumeroPersonne;
RUN;
DATA NouvAdherent_Feb2022;
SET NouvAdherent_Feb2022;
length Mois $20.;
Mois = "Février";
RUN;
/*****************************************/
/* Liste des adhérents fin février 2022 */
/*****************************************/
PROC SQL;
CREATE TABLE GarantieEnCours_Feb2022 AS
SELECT t1.IdTechPersonne,
t1.NumeroPersonne,
t1.EtatGarantie
FROM &table_Garantie_Histo t1
WHERE t1.FlagGarantieEnCours=1 and t1.DateDebutValidite <= mdy(3,1,2022) and t1.DateFinValidite >= mdy(3,1,2022);
QUIT;
DATA GarantieEnCours_Feb2022;
SET GarantieEnCours_Feb2022;
IF EtatGarantie in ("EnRenteViagere","EnServiceDeReversion","Réversion") then DELETE;
RUN;
PROC SORT data=GarantieEnCours_Feb2022 out=PortefeuilleAdherent_Feb2022 nodupkey;
by NumeroPersonne;
run;
PROC SQL;
CREATE TABLE Personne_Feb2022 AS
SELECT t1.NumeroPersonne,
t1.DateSaisieDecesDate
FROM &table_Personne_Histo t1
WHERE t1.DateDebutValidite <= mdy(3,1,2022) and t1.DateFinValidite >= mdy(3,1,2022);
QUIT;
PROC SQL;
CREATE TABLE PortefeuilleAdherent_Feb2022 AS
SELECT t1.*,
t2.DateSaisieDecesDate
FROM PortefeuilleAdherent_Feb2022 t1 left join Personne_Feb2022 t2 on t1.NumeroPersonne = t2.NumeroPersonne;
QUIT;
DATA PortefeuilleAdherent_Feb2022;
SET PortefeuilleAdherent_Feb2022;
WHERE DateSaisieDecesDate = .;
FlagDejaAdherent_Annee_N = 1;
DROP EtatGarantie DateSaisieDecesDate;
RUN;
PROC DATASETS lib=work nolist;
DELETE GarantieEnCours_Feb2022 Personne_Feb2022;
QUIT;
/********************************************/
/* Sortie Nouveaux adhérent en février 2022 */
/********************************************/
PROC SQL;
CREATE TABLE GarantieNouvAdherent_2022 AS
SELECT t1.*
FROM Garantie_2022 t1
WHERE (t1.NumeroComplet in (select t2.NumeroComplet from GarantieNouvAdherent_Jan2022 t2) or
t1.NumeroComplet in (select t3.NumeroComplet from GarantieNouvAdherent_Feb2022 t3)) and
t1.NumeroComplet not in (select t4.NumeroComplet from GarSortieNouvAdherent_Jan2022 t4);
QUIT;
PROC SQL;
CREATE TABLE GarSortieNouvAdherent_Feb2022 AS
SELECT t1.*
FROM GarantieNouvAdherent_2022 t1
WHERE t1.NumeroPersonne not in (select t3.NumeroPersonne from PortefeuilleAdherent_Feb2022 t3) and
t1.MotifCloture in ("Renonciation","Sans effet","Annulation","Refusé","Suppression");
QUIT;
PROC SORT DATA=GarSortieNouvAdherent_Feb2022 nodupkey out=SortieNouvAdherent_Feb2022;
BY NumeroPersonne;
RUN;
DATA SortieNouvAdherent_Feb2022;
SET SortieNouvAdherent_Feb2022;
length Mois $20.;
Mois = "Février";
RUN; |
Partager