The following code should work
use b.dta
sort id
save, replace
use a.dta, clear
sort id
joinby id using b.dta, unmatched( master )
On Wed, 7 Mar 2007, Roy,Suryadipta wrote:
Hi,
I have two datasets (a.dta and b.dta) as follows:
a.dta
id oid did x3
1 1 1 5
1 1 2 6
1 1 3 6
1 1 4 6
2 2 1 6
2 2 2 6
2 2 3 6
2 2 4 6
3 3 1 6
3 3 2 6
3 3 3 6
3 3 4 6
4 4 1 6
4 4 2 6
4 4 3 6
4 4 4 6
b.dta has observation missing for id=1:
id x1
1 .
2 12
3 13
4 14
I am trying to merge the two datasets such that the new dataset should read
as:
id oid did x3 x1
1 1 1 5 .
1 1 2 6 .
1 1 3 6 .
1 1 4 6 .
2 2 1 6 12
2 2 2 6 12
2 2 3 6 12
2 2 4 6 12
3 3 1 6 13
3 3 2 6 13
3 3 3 6 13
3 3 4 6 13
4 4 1 6 14
4 4 2 6 14
4 4 3 6 14
4 4 4 6 14
The common variable in both is "id" and both have already been sorted by
"id". I am getting the error message as "using data not sorted" or "variable
id does not uniquely identify observations in the master data".
Any help would be highly appreciated!!!
Thanks,
Suryadipta.
*
* 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/
*
* 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/