Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: FW: query on merging


From   Amal Khanolkar <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: FW: query on merging
Date   Mon, 1 Jul 2013 12:34:06 +0000

Hi,


I need some advice on the best way to merge two datasets, examples of which I've provided below:


Dataset 1:

mothers_id barn_lopnr barn_fodman malder

555        7467342     199312      36

555        12828480    198808      31

555        12205942    199103      34

573        5973947     198009      35

586        1126955     198810      37

....

....


Dataset 2:

mothers_id             SEI

5779163                 97

5779164                  .

5779165                 96

5779166                 11

5779169                 21

5779170                  .

....

....



In dataset 1 above, the first mother is included three times (id 555) as she has three children. In the second dataset, the mother is included just once as the SEI variable denotes her occupation. I need to tell STATA to merge information in dataset 2 to each unique mother in dataset 1 just once. I did the following:



sort mothers_id

merge m:1  mor_lopnr using "E:\Shared\Chess-BS\Amal\FoB80.dta"

tab _merge



. merge m:1  mor_lopnr using "E:\Shared\Chess-BS\Amal\FoB80.dta"

mor_lopnr was long now double



    Result                           # of obs.

    -----------------------------------------

    not matched                     7,041,840

        from master                   255,221  (_merge==1)

        from using                  6,786,619  (_merge==2)





    matched                         2,736,235  (_merge==3)

    -----------------------------------------

. 

end of do-file




© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index