Hello all,
I'm trying to merge two data sets. Data 1 contains the following variables: interview date, household longitude and latitude, cortisone level. (each row is a respondent).
Data 2 contains: longitude and latitude for entire country, rain levels by geographical coordinate from 2009 onwards. Temporal resolution is dekadal (10 days) so each month has 3 data points.
My goal is to merge the files together in order to determine the rainfall for each respondent in the 12 decads prior to interview data. I think that I need to do a 1:1 matched merge by longitude and latitude. Is this correct?
sort latitude longitude
merge 1:1 latitude longitude using "data2"
ERROR: variables latitude longitude do not uniquely identify observations in the master
data
Some of my troubleshoot ideas:
1.)
longitude and latitude in data 1 are stored as float variables at 9%g while
longitude and latitude in data 2 are stored as double variables at 10%g
I tried changing the format with the following code:
recast double longitude
recast double latitude
format longitude %10.0g
format latitude %10.0g
2.) longitude and latitude variables are rounded to .1 in data 2, while in data 1 they are rounded to several decimal places, so perhaps the variables cannot be matched due to the different precision levels? I tried changing the precision to .1 with the following code:
gen roundlongitude= round(longitude, .1)
gen roundlatitude= round(latitude, .1)
drop latitude
drop longitude
rename roundlatitude latitude
rename roundlongitude longitude
No success with those attempts. I'm not quite sure where I'm going wrong here, or if I'm even on the right track. Any help would be much appreciated! Thanks in advance.
Keily
I'm trying to merge two data sets. Data 1 contains the following variables: interview date, household longitude and latitude, cortisone level. (each row is a respondent).
Data 2 contains: longitude and latitude for entire country, rain levels by geographical coordinate from 2009 onwards. Temporal resolution is dekadal (10 days) so each month has 3 data points.
My goal is to merge the files together in order to determine the rainfall for each respondent in the 12 decads prior to interview data. I think that I need to do a 1:1 matched merge by longitude and latitude. Is this correct?
sort latitude longitude
merge 1:1 latitude longitude using "data2"
ERROR: variables latitude longitude do not uniquely identify observations in the master
data
Some of my troubleshoot ideas:
1.)
longitude and latitude in data 1 are stored as float variables at 9%g while
longitude and latitude in data 2 are stored as double variables at 10%g
I tried changing the format with the following code:
recast double longitude
recast double latitude
format longitude %10.0g
format latitude %10.0g
2.) longitude and latitude variables are rounded to .1 in data 2, while in data 1 they are rounded to several decimal places, so perhaps the variables cannot be matched due to the different precision levels? I tried changing the precision to .1 with the following code:
gen roundlongitude= round(longitude, .1)
gen roundlatitude= round(latitude, .1)
drop latitude
drop longitude
rename roundlatitude latitude
rename roundlongitude longitude
No success with those attempts. I'm not quite sure where I'm going wrong here, or if I'm even on the right track. Any help would be much appreciated! Thanks in advance.
Keily