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
| proc sql /* taille chaine <9 */
UPDATE matable
SET num_tel = 'NR'
where LENGTH(num_tel)<9 ;
run ;
proc sql /* taille chaine =9 et commence par 0 */
UPDATE matable
SET num_tel = 'NR'
where LENGTH(num_tel)=9
and num_tel LIKE 0% ;
run ;
proc sql /* taille chaine =9 et commence par 1 à 9 */
UPDATE matable
SET num_tel = '0'||num_tel
where LENGTH(num_tel)=9
and ( num_tel LIKE 1%
OR num_tel LIKE 2%
OR num_tel LIKE 3%
OR num_tel LIKE 4%
OR num_tel LIKE 5%
OR num_tel LIKE 6%
OR num_tel LIKE 7%
OR num_tel LIKE 8%
OR num_tel LIKE 9%) ;
run ;
data matable; /* taille chaine =10 et commence par 1 à 9 , ici faute de frappe avec chiffre en double*/
set matable
if COUNTC(num_tel)=10
and char(num_tel,1)<>'0' ;
num_tel=tranwrd(num_tel,'00','0');
num_tel=tranwrd(num_tel,'11','1');
num_tel=tranwrd(num_tel,'22','2');
num_tel=tranwrd(num_tel,'33','3');
num_tel=tranwrd(num_tel,'44','4');
num_tel=tranwrd(num_tel,'55','5');
num_tel=tranwrd(num_tel,'66','6');
num_tel=tranwrd(num_tel,'77','7');
num_tel=tranwrd(num_tel,'88','8');
num_tel=tranwrd(num_tel,'99','9');
/* au final si il y a plus de 2 doublons de chiffre la longueur de chaine est reduite et passe à 8 et moins donc on va mettre NR , sinon si la longueur de chaine passe à 9 on concatene un 0 devant la chaine */
run;
proc sql /* taille chaine =11 et commence par 1 à 9 */
UPDATE matable
SET num_tel = 'NR'
where LENGTH(num_tel)=11
and ( num_tel LIKE 1%
OR num_tel LIKE 2%
OR num_tel LIKE 3%
OR num_tel LIKE 4%
OR num_tel LIKE 5%
OR num_tel LIKE 6%
OR num_tel LIKE 7%
OR num_tel LIKE 8%
OR num_tel LIKE 9%) ;
run ;
data matable; /* taille chaine =11 et commence par 0 , ici faute de frappe avec chiffre en double*/
set matable
if COUNTC(num_tel)=11
and char(num_tel,1)='0' ;
num_tel=tranwrd(num_tel,'00','0');
num_tel=tranwrd(num_tel,'11','1');
num_tel=tranwrd(num_tel,'22','2');
num_tel=tranwrd(num_tel,'33','3');
num_tel=tranwrd(num_tel,'44','4');
num_tel=tranwrd(num_tel,'55','5');
num_tel=tranwrd(num_tel,'66','6');
num_tel=tranwrd(num_tel,'77','7');
num_tel=tranwrd(num_tel,'88','8');
num_tel=tranwrd(num_tel,'99','9');
/* au final si il y a plus de 2 doublons de chiffre la longueur de chaine est reduite et passe à 9 et moins donc on va mettre NR , sinon si la longueur de chaine passe à 10 garder la chaine a 10 */
run;
proc sql; /* taille chaine =11 et commence par 00 , ici faute de frappe avec chiffre en double debut*/
UPDATE matable
SET num_tel = right(num_tel,10)
where LENGTH(num_tel)=11
and num_tel LIKE 00% ;
/* au final les 00 du debut deviennent 0*/
run;
proc sql; /* taille chaine 0et commence par 00 , ici faute de frappe avec chiffre en double debut*/
UPDATE matable
SET num_tel = 'NR'
where LENGTH(num_tel)=10
and num_tel LIKE 00% ;
/* au final on met NR */
run; |
Partager