Statalist


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

Re: st: merging in panel


From   John Antonakis <[email protected]>
To   [email protected]
Subject   Re: st: merging in panel
Date   Fri, 23 Jan 2009 20:15:59 +0100

-joinby- does the trick!

What a useful command!

Thanks and have good weekend.
J.
____________________________________________________

Prof. John Antonakis
Associate Dean
Faculty of Business and Economics
University of Lausanne
Internef #618
CH-1015 Lausanne-Dorigny
Switzerland

Tel ++41 (0)21 692-3438
Fax ++41 (0)21 692-3305

____________________________________________________



On 23.01.2009 20:11, Scott Merryman wrote:
> I think you want -joinby-
>
> clear
> input id x y
> 1 5 6
> 1 6 8
> 1 7 8
> 1 4 9
> 2 1 3
> 2 0 1
> end
>
> tempfile foo
> sort id
> save `foo'
>
> clear
> input id z
> id z
> 1 7
> 2 5
> 3 4
> end
>
> sort id
> joinby id using `foo'
> l
>
>
> Scott
>
> On Fri, Jan 23, 2009 at 1:01 PM, John Antonakis <[email protected]> wrote:
>> I have a file with panel data, like this:
>>
>> id x y
>> 1 5 6
>> 1 6 8
>> 1 7 8
>> 1 4 9
>> 2 1 3
>> 2 0 1
>> etc.
>>
>> Now, I have another file that observations that are invariant at the id
>> level:
>>
>> id z
>> 1 7
>> 2 5
>> 3 4
>> etc.
>>
>> I want to merge the two files to get this:
>>
>> id x y z
>> 1 5 6 7
>> 1 6 8 7
>> 1 7 8 7
>> 1 4 9 7
>> 2 1 3 5
>> 2 0 1 5
>> etc.
>>
>> How can -merge- handle this?
>>
>> Thanks,
>> John
> *
> *   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/

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