原始数据截图:
处理效果:
两列数据处理方法见帖子:
https://bbs.pinggu.org/thread-11172305-1-1.html
需要将命令修改为:
qui levelsof year, local(years)
foreach i of local years{
g holding= auditor1
bys stkcd (year): g tag= auditor1==auditor2[_n-1]| auditor2==auditor1[_n-1]
qui replace auditor1= auditor2 if tag
qui replace auditor2= holding if tag
drop tag holding
}