Statalist


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

Re: st: Merging unbalanced datasets


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: Merging unbalanced datasets
Date   Mon, 16 Jun 2008 18:25:36 -0400

Leonor Saravia and Andrea Bennett--
Actually, you need not -sort- before you -joinby- but you would want
the -unm(both)- option on -joinby- so you can -tab _m- afterwards and
see if everything merged properly.  But -merge- also works fine here:
when Stata tells you that "variable id does not uniquely identify
observations in the master data", that is merely a statement of fact
(look at your sample data below), and not something you need to worry
about.

On Mon, Jun 16, 2008 at 6:00 PM, Andrea Bennett <[email protected]> wrote:
> Dear Leonor,
>
> To me that looks like you should check out the Stata command -joinby- (see
> help joinby) which does exactly what you need. Both data sets need to be
> sorted according to your unique identifier (in your case -id- I guess)
> before you can execute the joinby command.
>
> Kind regards,
>
> Andrea
>
>
> On Jun 16, 2008, at 11:37 PM, Leonor Saravia wrote:
>
>> Dear Statalisters,
>>
>> I'm having trubles when I try to merge two datasets that have
>> different number of rows, because one of them has the individuals
>> labor history and the other only has some characteristics of them.
>>
>> The first dataset ("first") looks like this:
>>
>> id      job_history    inicial_year    finish_year
>> 1          waitress         1980             1985
>> 1          self-empl.        1986             1991
>> 1         unemployed     1992             2000
>> 2          journalist         1985             1990
>> 2          unemployed      1991            2005
>> .
>> .
>> 6          economist       1990             1999
>> 6          self-empl.        2000             2008
>>
>>
>> And the second ("second") one like this:
>>
>> id      sex       age
>> 1        F          20
>> 2        M         75
>> .
>> .
>> 6       F           60
>>
>> So, when I try to merge those datasets using the "first" data set as
>> the master data, Stata tells me that "variable id does not uniquely
>> identify observations in the master data", and I don�t know how to
>> deal with this, so I'd appreciate if you could help me.
>>
>> Thank you!
>>
>> Leonor

*
*   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/



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