Hello STATA friends,
I'm trying to merge inventory datasets. There is one with unique IDs (SKUs) and revenue data across all years, then 5 more datasets with the SKUs each across only a single year with price data (all in the same format). Here's the code.
forvalues i = 11/16 { merge m:1 year sku using "$int\price20`i'.dta", force drop _merge }
However, when it loops through, the matched observations don't append, but replace the observations from the prior year. When the loop finishes, there's only one year's worth of price data remaining. Any thoughts as to how to fix?
I'm trying to merge inventory datasets. There is one with unique IDs (SKUs) and revenue data across all years, then 5 more datasets with the SKUs each across only a single year with price data (all in the same format). Here's the code.
forvalues i = 11/16 { merge m:1 year sku using "$int\price20`i'.dta", force drop _merge }
However, when it loops through, the matched observations don't append, but replace the observations from the prior year. When the loop finishes, there's only one year's worth of price data remaining. Any thoughts as to how to fix?
Comment