Hi!
I'm working on household and individual survey data. I'm trying to merge two datasets using the "merge" command for Stata and I'm having some difficulties.
I'd like to merge two datasets using the "hhcode" variable which is the household number; however, in the master dataset, there are multiple individuals (id) in the household so the code appears multiple times. In the other dataset, the data is simply about the household (there is no id data).
Whenever I want to merge the datasets, Stata gives me -justifiably so- the r(459) error message "variable hhcode does not uniquely identify observations in the master data".
I don't know how I can solve/work around this problem. I've tried switching the master and using datasets and different merging configurations (1:1, 1:m, m:1) but the problem remains.
The two datasets look like this:
Thank you!
I'm working on household and individual survey data. I'm trying to merge two datasets using the "merge" command for Stata and I'm having some difficulties.
I'd like to merge two datasets using the "hhcode" variable which is the household number; however, in the master dataset, there are multiple individuals (id) in the household so the code appears multiple times. In the other dataset, the data is simply about the household (there is no id data).
Whenever I want to merge the datasets, Stata gives me -justifiably so- the r(459) error message "variable hhcode does not uniquely identify observations in the master data".
I don't know how I can solve/work around this problem. I've tried switching the master and using datasets and different merging configurations (1:1, 1:m, m:1) but the problem remains.
The two datasets look like this:
Code:
input double(hhcode id) int year 31010101420086 3101010142008601 2008 31010101420086 3101010142008602 2008 31010101420086 3101010142008603 2008 31010101420299 3101010142029901 2008 31010101420299 3101010142029902 2008 31010101420299 3101010142029903 2008 31010101420354 3101010142035401 2008 31010101420354 3101010142035402 2008 31010101420354 3101010142035403 2008 31010101420762 3101010142076201 2008 31010101420762 3101010142076202 2008 31010101420762 3101010142076203 2008 31010101420866 3101010142086601 2008 31010101420866 3101010142086602 2008 31010101420866 3101010142086603 2008 end label values hhcode hhcode label values id id
Code:
input double hhcode int year 31010101420086 2008 31010101420299 2008 31010101420354 2008 31010101421029 2008 31010101500091 2008 31010101500112 2008 31010101500212 2008 31010101500365 2008 31010101500398 2008 31010101720165 2008 31010101720363 2008 31010101900030 2008 31010101900030 2008 31010101900226 2008 31010300920137 2008 end label values hhcode hhcode
Comment