之前一直对merge m:m不感冒,直到最近才发现它的好处。
废话少说,上log
set obs 300
egen id=seq()
gen firm=1
save "firmid"
clear
set obs 10000
egen id=seq()
replace id=int(id/100) if id>100*there will be firm id greater than 100
gen employ=id+100
save "employ"
*i plan to assign each employ value in eploy.dta to firid.dta
use firmid.dta
sort id
merge m:m id using employment
*in this case, all firm id are kept
clear
use firmid.dta
joinby id using employ.dta
*in this case, only id <=100 are kept.
唉,怪自己不认真那