Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Merging of two datasets

From   Tobias Brütsch <>
To   <>
Subject   st: Merging of two datasets
Date   Tue, 8 May 2007 21:06:00 +0200

Dear Statalister 

I know, I have lots of questions at the moment, but I am a new user of stata
and I have some problems to manage my data and I hope I could get some
hint's from experienced users.

I am trying this since last week and I cant find the solution.

I have to match two datasets from two diffrend sources but about the same

Dataset1 (+/- 5000 observations): 
date            Firm     recommendation  brokerID 
15.03.2002      ABB             2        LEHM
11.01.2005      ABB             5        HESLB 
01.07.2005      ABB             2        JBCOB 
06.08.2004      ABB             3        MORGAN 

Dataset2 (+/- 2500 observations): 
Date             firm                brokerID        recommendation 
04aug2003        ABB                 MORGAN               4 
13nov2002        ABB                 WAREURO              4 
22mar2005        ABB                 JYSKE                4 
25jan2005        ABB                 SOGENED              4 
27jan2004        ABB                 PARIBEU              3 

Where Firms and the brokers are the same. Dates are from 2001 to 2005. 

Now i want to analyse if the recommendations of Dataset 2 are:

1. the same like these in set 1 (should be for some but I think not for all)
2. The recommendations in set 2 are published with a certain lag, perhabs
5-10 days after the same recommendation in set1. 

Now i don’t know to merge the sets. It wont work by the brokerID, nor by the
firm nor by data because of the time lag (this varies from a few days to

I also tried to make new keyvariables with egen group but this doesn't work

For example the keyvariable (-group(firm brokerID recommendation)) has to
much duplicate observations (MorganSt. published a 3 for ABB several times).

I also tried to generate new indices by _n or by _N but it wasnt the
It didn’t workt to, if I just merged it by -merge firm broker week- or -firm
broker month- (I excludet the week or the month out of date).

Are there possible ways to merge these sets??

Thank you all! 

Best regards

Tobi Brütsch

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index