keep loanId borrowerId
cd "C:\Users\Lenovo\OneDrive\XXXXXXXX"
merge m:1 loanId using "borrower"
drop if _merge!=3
drop _merge
cd "D:\XXXX"
merge m:m borrowerId using "borrower1"
drop if _merge!=3
save link113-1.dta
keep borrowerId
save inverstor.dta
use link113-1.dta, clear
drop _merge
merge m:m borrowerId using "inverstor"
drop if _merge!=3
drop _merge
save activelink.dta
***note:为了调出哪些investor从来没作为borrower借过钱,以及哪些borrower从来没作为investor投过钱,这里进行了两次匹配。所以,在上述merge命令中将link数据集中的investor那一列的名字改为borrower,以方便匹配。第二次操作原理与此相同。