Statalist


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

Re: st: merge command doesn't work???


From   David Kantor <[email protected]>
To   [email protected]
Subject   Re: st: merge command doesn't work???
Date   Thu, 28 Aug 2008 14:20:24 -0400

At 02:11 PM 8/28/2008, Kokootchke (Adrian) wrote:
It is more likely that I am the one who doesn't work, but I don't understand what I'm doing wrong.

I have a dataset that looks like this:

sic87 isic3
...
3199 1810
3199 1912
3199 1920
3199 3699
...
2021 1520
2022 1520
2022 1549
2023 1520
2024 1520
2026 1520
...

and another one that looks like this:

sic87 year emp
3199 1980 50
3199 1990 70
3199 2000 85
2021 1980 57
2021 1990 65
2021 2000 95
2022 1980 17
2022 1990 23
2022 2000 25
...

If I sort both datasets by sic87, start with the second one and type:

merge sic87 using firstdataset

shouldn't I get something that looks like this:

sic87 year emp isic3
3199 1980 50 1810
3199 1980 50 1912
3199 1980 50 1920
3199 1980 50 3699
3199 1990 70 1810
3199 1990 70 1912
3199 1990 70 1920
3199 1990 70 3699
...

that is, because I am not specifying that the observations in either the master or the using data sets should be unique, then stata should expand my master data set, repeating every row in the master data set for every repeated row in using data set with same sic87 but different isic3, no?

I know this has to do with how stata handles the unique values in both the master and the using data sets, but I don't know what's going on.

I hope you guys can tell me what I'm doing wrong.
Use -joinby- rather than -merge-.
HTH
--David

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index