Hi all,
I am merging a number of different datasets and am having trouble with the merge command "deleting" cell values.
My starting panel dataset looks like this:
I wish to merge it with a dataset that looks like this (i.e., adding two additional variables to the dataset):
However, when I use the merge command Stata "deletes" the original variables (var1 and var2) and turns them into missing values.
The dataset ends up looking like this:
Here's the basic code I'm using. Sometimes the problem doesn't occur for the first dataset I'm merging and then the deletion happens for the remaining datasets I'm attempting to merge.
Any help would be much appreciated. Thank you!
Matt
I am merging a number of different datasets and am having trouble with the merge command "deleting" cell values.
My starting panel dataset looks like this:
Code:
county year var1 var2 1 1 25 30 1 2 35 22 1 3 40 50 2 1 34 30 2 2 45 44 2 3 56 21 3 1 23 12
Code:
county year var3 var4 1 1 27 28 1 2 34 32 1 3 43 42 2 1 32 33 2 2 43 24 2 3 67 23
The dataset ends up looking like this:
Code:
county year var1 var2 var3 var4 1 1 . . 27 28 1 2 . . 34 32 1 3 . . 43 42 2 1 . . 32 33 2 2 . . 43 24 2 3 . . 67 23
Code:
merge m:1 county year using "X.dta"
Matt
Comment