Statalist


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

Re: st: merging in panel


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: merging in panel
Date   Fri, 23 Jan 2009 13:11:22 -0600

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/



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