修改一下楼上的程序
use test, clear
keep firm product
save product, replace
use test, clear
keep firm destination
save destination, replace
joinby firm using product
sort firm product
duplicates drop
merge 1:m firm product destination using test
drop _merge
replace value=0 if value==.
sort firm product destination value