Please post the code you already have. Relying upon a single function result to alter an EMail-address can cause false replacements. Just an idea: data work.want; set work.have; length DomainList $ 100 Domain $ 20 i minId minCost cost 8 NewEMail $ 100 ; /* List of valid domains, if the list is longer: store it in another dataset and use a hash-object */ retain DomainList "GMAIL.COM YAHOO.COM HOTMAIL.COM"; /* Anything on the left of @ is unimportant */ Domain = scan(Email, 2, '@'); minCost = constant('BIG'); /* do i = 1 to countw(DomainList, ' '); cost = spedis(Domain, scan(DomainList, i, ' ')); if cost < minCost then do; minCost = cost; minId = i; end; end; NewEMail = catx('@', scan(Email, 1, '@'), scan(DomainList, minId, ' ')); run;
... View more