【问题标题】:Exact matching on >= 1 variable and fuzzy matching on >=1 variable stata>= 1 变量的精确匹配和 >= 1 变量状态的模糊匹配
【发布时间】:2020-10-02 01:48:48
【问题描述】:

在 Stata 中,如何对至少一个变量进行精确匹配以及对至少一个变量进行模糊匹配?

例如,假设我想对orgyear 进行精确匹配,对firstnamelastname 进行模糊匹配。换句话说,为了让它甚至考虑对firstnamelastname的模糊匹配,orgyear必须是完全匹配的。

这是一个示例数据集:

*dataset a
clear all
input str1 org year str10 firstname str12 lastname
"A" 2010 "susan" "robertson"
"A" 2011 "bob" "miller"
"B" 2010 "albert" "smith"
"B" 2011 "sue" "washington"
end
tempfile a
save `a'

还有一个,要合并:

*dataset b
clear all
input str1 org year str10 firstname str12 lastname
"A" 2010 "Susan A" "Robertson"
"A" 2011 "bob" "Miller"
"A" 2012 "francisco" "ramirez"
"B" 2010 "mike" "doorpen"
"B" 2011 "sue h" "washnngton"
end
tempfile b
save `b'

我怎样才能完成我想要的?

我能想到的最好的方法是将firstnamelastname 组合成一个变量后使用matchit,例如name。然后,对于具有相同orgyear 的观察,只保留高于某个阈值的模糊匹配结果。但这似乎很笨拙。有没有更好的办法?对所有方法开放。

【问题讨论】:

  • 当不需要的匹配数量很高时,“笨拙”特别强。例如,当有很多年和组织时。

标签: merge match stata


【解决方案1】:

有人在 Twitter 上告诉我答案:使用 reclink (https://fmwww.bc.edu/repec/bocode/r/reclink.html) 和 required 选项。

【讨论】:

    猜你喜欢
    • 2018-06-09
    • 2015-10-03
    • 2019-01-17
    • 2021-01-26
    • 1970-01-01
    • 1970-01-01
    • 2012-03-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多