Dear Stata support,
I have a question on merging two datasets.
Assume that I have two datasets as followings:
Master dataset is named "file1" and contains two variables:
ID var1
A 1
A 2
B 3
The using dataset is named "file2: and also contains two variables:
ID var2
A 4
A 5
A 6
I would like to merge these two files. I expect to get a new file
(file3) as followings:
ID var1 var2
A 1 4
A 1 5
A 1 6
A 2 4
A 2 5
A 2 6
B 3 .
However, after I sort both datasets by ID and then type command:
merge ID using file2.dta
The resulted file is not what I expected.
I was wondering why this happens? Can I use merge command to obtain the
file3? Thanks a lot,
Sincerely,
Jian Zhang
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/