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