Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Merging only the common elements, and dropping duplicates


From   George Chioran <george_chioran@yahoo.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Merging only the common elements, and dropping duplicates
Date   Wed, 16 Jun 2010 00:13:53 -0700 (PDT)

Dear statalisters, 
 
I am trying to merge 2
databases to match persons with accounts; however I discovered that when I do
this, the final database contains a lot of duplicates. 
Database 1 looks like
this. I sort it by account. 

Person  Account
2              311
2              311
2              311
2              311
2              413
2              413
2              413

Database 2 looks like
this. I sort it by account.

Account B_S
311         b
311         b
311         b

To merge them, I load
database 1 and merge it using database 1. But when I do this, I would like to
have a final database that contains only the common observation of both. But I get database 3
that looks like this.

Person Account B_S
2              311         b
2              311         b
2              311         b
2              311         b
2              413         .
2              413         .
2              413         .
 
Is there a way to get
just the common observations? I would like my final database to have just:
Person Account B_S

2              311         b
2              311         b
2              311         b

Thank you, 
George


      
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index