Hello!
I am trying to merge two datasets from a survey which contains household ((HH) level data with different variables and thus value labels. First of all, I had to convert these datasets from SPSS to Stata, and then merging them through its common identificator name as, let's say, id. Thus, I used the following command:
use household.dta, clear
merge 1:1 id using using.dta
This succesfully merges the two datasets, but the problem is that the labels of the variables are changed. For example, before merging the datasets, we could have two variables as follows:
HH_A: Categorical variable in master dataset that takes the values of
1 = "X"
2 = "Y"
3 = "Z"
HH_1: Categorical variable in using dataset that takes the values of
1 = "A"
2 = "B"
3 = "C"
When both datasets are merged, HH_1 wrongly takes the value labels of the variable in the master dataset, so that for the values that are equal to 1 the label showed in the merged dataset is X, for 2 "Y" and for 3 "Z", which does not make any sense. How could I fix this? I already tried to reformulate the command so that:
use using.dta, clear
merge 1:1 id using household.dta, nolabel
as nolablel is supposed to order Stata not to copy value-label definitions from using, but this does not work either and the value labels are mixed again but the other way around.
I thank you for the guidance in advance!
Best,
Michelle
Related Posts with Merge while keeping value labels in master and using dataset unchanged
Fixed effect model with controlled variablesHi all. I am using a fixed-effect model to reveal the impact of some factors on the land price (I ha…
closest relative match based on multiple variables after exact matchingDear Statalisters, I have the following problem: I am trying to match two survey waves (let's call …
Code segment conditional on variable existenceHi All, I am trying to do a loop over multiple variables to create a histogram for caller frequency…
Rangestat: value weighted variance and skewnessDear Stata users I need to calculate equially- and value-weighted variance and skewness for each id…
automatically creating year variable for panel dataHi, I am a beginner in Stata. recently I spent a lot of day in creating a panel data, I have a huge …
Subscribe to:
Post Comments (Atom)
0 Response to Merge while keeping value labels in master and using dataset unchanged
Post a Comment