Hi, Well, if the first letter is always indicative, then just check that: data have; length email $200.; input email $; cards; XXX@GMMIL.COM YYY@GMIL.COM ZZZ@GMAILL.COM XXX@YAHOOO.COM YYY@YHOO.COM ZZZ@YAHOHO.COM XXX@HOOTMAIL.COM YYY@HAATMAIL.COM ZZZ@HITMAIL.COM ; run; data want; length newmail $200.; set have; select(substr(scan(scan(email,2,'@'),1,'.'),1,1)); when ('G') newmail=scan(email,1,'@')||"@GMAIL.COM"; when ('Y') newmail=scan(email,1,'@')||"@YAHOO.COM"; when ('H') newmail=scan(email,1,'@')||"@HOTMAIL.COM"; otherwise newmail=""; end; run;
... View more