The issue arises, since plenty of city in different states have multiple county code/county name as I'm showing a part of duplicates ( from my using data ) data with same city and state but different county name /couty_fip code.
Code:
list city state_id county_name, sepby(city state_id) noobs +---------------------------------------+ | city state_id county_name | |---------------------------------------| | Midway FL Gadsden | | Midway FL Santa Rosa | | Midway FL Seminole | |---------------------------------------| | Woodbury NY Nassau | | Woodbury NY Orange | |---------------------------------------| | Oakwood OH Cuyahoga | | Oakwood OH Montgomery | | Oakwood OH Paulding | |---------------------------------------| | Franklin PA Cambria | | Franklin PA Venango | |---------------------------------------| | Georgetown PA Beaver | | Georgetown PA Lancaster | | Georgetown PA Luzerne | |---------------------------------------|
dataex id city statefip if city=="Georgetown" & statefip=="PA"
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str14 id str43 city str3 statefip "11311793" "Georgetown" "PA" "12054868" "Georgetown" "PA" "13761470" "Georgetown" "PA" "63145796" "Georgetown" "PA" "63058645" "Georgetown" "PA" "11415903" "Georgetown" "PA" "62891646" "Georgetown" "PA" "10933939" "Georgetown" "PA" "17385483" "Georgetown" "PA" "10925795" "Georgetown" "PA" end
dataex city statefip county_fips county_name if city== "Georgetown" & statefip=="PA"
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str35 city str2 statefip long county_fips str21 county_name "Georgetown" "PA" 42007 "Beaver" "Georgetown" "PA" 42071 "Lancaster" "Georgetown" "PA" 42079 "Luzerne" end
When I'm using m:1
Code:
merge m:1 city statefip using "using.dta", keep(master match) nogen variables city statefip do not uniquely identify observations in the using data r(459); end of do-file r(459);
Code:
merge 1:m city statefip using "city_countyfipshort.dta", keep(master match) nogen variables city statefip do not uniquely identify observations in the master data r(459); end of do-file r(459);
0 Response to Error merging master data with using data keeping the merge key as city and statefip
Post a Comment