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
| data a;
length adresse $255.;
adresse = "7 rue du château 11000 CARCASSONNE"; output;
adresse = "12 bis rue de la plage 34000 MONTPELLIER"; output;
adresse = "9 Avenue du canal 31000 TOULOUSE"; output;
adresse = "14,rue de l'église 77380COMBS LA VILLE"; output;
;
run;
data b;
retain prxid;drop position taille prxid prx;
if _N_=1 then do;
prx="/(\d{5})[ ]*(.+)/";
prxid=prxparse(prx);
IF missing(prxid) Then do;
putlog "ERREUR:Expression Régulière Invalide :" prx;
stop;
end;
end;
length adresse $255. cp $5. ville $32.;
set a;
if ^prxmatch(prxid,adresse)then
putlog "AVERTISSEMENT:pas de localité valide dans l 'adresse :" adresse;
else do;
call prxposn(prxid,0,position,taille);
cp_ville=substr(adresse,position,taille);
call prxposn(prxid,1,position,taille);
cp=substr(adresse,position,taille);
call prxposn(prxid,2,position,taille);
ville=substr(adresse,position,taille);
end;
run;
data b;
set b;
rue=substr(adresse,1,length(adresse)-length(cp_ville));
run; |
Partager