I am having Mob no if length =10 and first digit ne 0 then i should not consider that at that point the data should be '' if length =11 and first digit=0 then i should remove the 0 and take the rest in to variable if length =12 and first two digit=91 then i should remove the 91 and take the rest in to variable data t1; infile cards missover truncover; input name $ Mob_No $ 3-20; org=mob_no; cards; a 91+1234506789 a 98-12345678 a 01234506789 a 1234506789 a M-1234506789 a b-1234506789 a 911234506789 a 911234506789 a 01234506789 a 8989 a 98123456789 a 0123456789 a 1234056789 ; run; data test; set t1; Mob_No=upcase(Mob_No); Mob_No=trim(compress(Mob_No,' +-_()ABCDEFGHIJKLMNOPQRSTUVWXYZ')); mob_len=length(Mob_No); if mob_len in(10,11,12) then Mob_No=Mob_No; else Mob_No=''; if mob_len=10 and substr(Mob_No,1,1) ne '0' then Mob_No=Mob_No; else if mob_len=11 and substr(Mob_No,1,1)='0' and substr(Mob_No,2,1) ne '0' then Mob_No=substr(Mob_No,2,12); else mob_no=mob_no; if mob_len=12 and substr(Mob_No,1,2)='91' and substr(Mob_No,3,1) ne'0' then Mob_No=substr(Mob_No,3,12); else mob_no=mob_no; /*/*Mob_No1=Mob_No;*/*/ /*/*Mob_len2=length(Mob_No1);*/*/ /*/*if mob_len2=11 and substr(Mob_No1,1,1) ='0' then Mob_No1=substr(Mob_No1,2,12);*/*/ /*/*else if mob_len2=12 and substr(Mob_No1,1,2)='91' then Mob_No1=substr(Mob_No1,3,12);*/*/ /*/*else Mob_No1=Mob_No1;*/*/ run; proc print; run; output should be a 1234506789 a 9812345678 a 1234506789 a 1234506789 a 1234506789 a 1234506789 a 1234506789 a 1234506789 a 1234506789 a a a a 1234056789
... View more