您的位置:首页 > 娱乐 > 八卦 > 【stata】处理城市名和城市代码

【stata】处理城市名和城市代码

2024/10/5 20:21:06 来源:https://blog.csdn.net/weixin_43168119/article/details/142036081  浏览:    关键词:【stata】处理城市名和城市代码

写了两个简单的外部命令,在这里分享一下,希望能帮到大家

1.citycode_mutate

第一个命令是citycode_mutate,用于识别字符串中可能存在的城市信息,并生成城市代码(图1图2)。

fig1

fig2

2.cityname_mutate

第二个命令是cityname_mutate,可将城市代码转换成统一的城市名(图3图4)。
fig3

fig4

(背后的逻辑其实就是基于正则表达式)

3.安装方法

net install citycode_mutate, from("https://mengke25.github.io/files/function/stata/citycode_mutate") replace 
net install cityname_mutate, from("https://mengke25.github.io/files/function/stata/cityname_mutate") replace

转载请注明出处@mengke25

请喝咖啡打赏渠道