按列内SAS中的相似字符串分组

  • 本文关键字:相似 字符串 SAS sas
  • 更新时间 :
  • 英文 :


我有以下表格:

Name
----
John Smith
John Smth
Jane Lee
Jane Line
Timothy Brown
Timmothy Brown
Agnes James
Aaron James

使用SAS,我如何对这些字符串进行大规模分组以识别那些相似的字符串,以便我可以得到这个表:

Name
----
John Smith
John Smth
Timothy Brown
Timmothy Brown

在SAS中有许多方法来执行字符串比较。一个简单的例子是使用SOUNDEX查找声音相似的两个字符串。

data have;
input Name $char20.;
datalines;
John Smith
John Smth
Jane Lee
Jane Line
Timothy Brown
Timmothy Brown
Agnes James
Aaron James
;
proc sql;
create table want as
select 
A.name
, B.name as name2
, soundex(A.name) as sxname
, soundex(B.name) as sxname2
from have a
cross join 
have b
where a.name lt b.name
having sxname = sxname2
;

其他技术将使用基于度量(如Levenshtein编辑距离)的匹配标准,该标准可以使用COMPLEV计算。您还可以了解更多关于SPEDIS的信息。

搜索如何使用SAS函数执行模糊匹配,您将得到很多咀嚼。关注Charles Patridge的文章

最新更新