I have two datasets. First:
countyGroup income other_data_ 1 20990 β¦ 2 25622 β¦ 3 24289 β¦ 4 27391 β¦ 5 23326 β¦ 6 19261 β¦ 7 15197 β¦ 8 11132 β¦
Second:
countyGroup state county other_data 1 IL 123 β¦ 1 IL 123 β¦ 2 MI 365 β¦ 1 IL 123 β¦ 3 AK 65 β¦ 4 IL 546 β¦ 5 MI 689 β¦ 6 AK 32 β¦
The countyGroup variable uniquely identifies both state and county . The second dataset contains countyGroup , state and county . The first data set contains only countyGroup . I need to create two variables ( state and county ) in the first data set.
I tried matching values ββwith merge :
use dataset1 merge 1:m countyGroup using dataset2, keepusing(state state cntyfp) update replace
The result that I get is duplicate rows ... I tried 1:1 , it did not work ... I can always drop duplicate rows, but I wanted to merge them correctly from the very beginning.
source share