Hi everyone,
I'm trying to merge two datasets: one with accounting data for several
companies and the other with monthly stock returns and market value. I'm
using the following command:
. merge dscd Year Month using "C:\DATA\mktdata\ret_mv.dta", unique sort
With the accounting data loaded in memory.
After running this command I edited the merged file and found that stata
used all the observations from ret_mv.dta, even though the accounting data
file only has information for one Year and one Month per observation. Ex.:
Accouting data
Id Year Month TotalAssets
1 1990 6 1000
1 1991 6 1100
1 1992 6 1200
2 1995 6 200
2 1996 6 400
2 1997 6 500
...
Ret_mv.dta
Id Year Month RET MV
1 1990 1 .1 100
1 1990 2 .2 120
1 1990 3 .1 132
1 1990 4 0 132
1 1990 5 .1 155
1 1990 6 0 155
1 1990 7 .2 185
1 1990 8 0 185
...
The after running the merger command I get the following:
Id Year Month TotalAssets RET MV
1 1990 1 . .1 100
1 1990 2 . .2 120
1 1990 3 . .1 132
1 1990 4 . 0 132
1 1990 5 . .1 155
1 1990 6 1000 0 155
1 1990 7 . .2 185
1 1990 8 . 0 185
...
But the results should have been:
Datamerged
Id Year Month TotalAssets RET MV
1 1990 6 1000 0 155
1 1991 6 1100 x y
1 1992 6 1200 xx yy
...
Can anyone explain why this happens and if there is any way of solving this
issue?
Best,
AS
*
* 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/