like this 🙂 data phonenumbers;
input phone $;
format phone $12.;
datalines;
4345121
464158245
29767111
998625676
63465126026
639208907675
;
data want(drop = code);
set phonenumbers;
if length(Phone) <= 7 then code = '00632';
else if length(Phone) = 8 then code = '0063';
else if length(Phone) = 9 and substr(Phone, 1, 2) in ('46', '32', '82') then code = '0063';
else if length(Phone) = 11 and substr(Phone, 1, 2) = '63' then code = '00';
else if length(Phone) = 9 and substr(Phone, 1, 1) = '9' then code = '0063';
else if length(Phone) = 12 and substr(Phone, 1, 3) = '639' then code = '00';
newphone = cats(code, phone);
format newphone $12.;
run;
... View more