在Sas中拆分电子邮件地址

时间:2014-01-08 04:24:34

标签: sas

有人知道如何拆分SAS中的电子邮件地址吗?情况就是这样:

happy_new_year@gmail.commakannasi@yahoo.co.idnasigoreng@abc.net

然后将文本分成以下内容:

happy_new_year@gmail.com|makannasu@yahoo.co.id|nasigoreng@abc.net
直到现在,我还没有找到最好的解决办法。

感谢

1 个答案:

答案 0 :(得分:1)

正如评论所说,对于大量。* TLD而言,这可能会非常棘手。更不用说你可能有一个tld与下一个地址的第一个字母看起来像另一个tld。 I.E.如果.xy和.xyz都是tlds,me@here.xyzed@here.com将是不明确的。是me@here.xy|zed@here.com还是me@here.xyz|ed@here.com

那说我会这样开始接近它。

%let tlds = .com .net .edu .blah .fu .bar;

data _null_;
format str $2000.;
str = "bob@here.comchris@xyz.blahme@hrm.fu";

tlds = "&tlds";
format tld $4.;
do i=1 to countw(tlds);
    tld = scan(tlds,i);
    str = tranwrd(str,strip(tld),strip(tld)||"|");
end;
put str;
run;

返回

bob@here.com|chris@xyz.blah|me@hrm.fu|

根据需要添加逻辑,如附加tld或新逻辑。

相关问题