Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Sum of specific observations of the same variable


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Sum of specific observations of the same variable
Date   Tue, 4 Mar 2014 09:58:25 +0000

This is often asked here. Search the archives for citations of

SJ-8-4  dm0043  . Tip 71: The problem of split identity, or how to group dyads
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q4/08   SJ 8(4):588--591                                 (no commands)
        tip on how to handle dyadic identifiers

http://www.stata-journal.com/sjpdf.html?articlenum=dm0043

In essence,

. generate first = cond(reporter < partner, reporter, partner)
. generate second = cond(reporter < partner, partner, reporter)

followed

. collapse (sum) trade, by(first second)

or

egen total = total(trade), by(first second)

Nick
[email protected]


On 4 March 2014 07:45, Andreas Dimopoulos <[email protected]> wrote:

> I have data on bilateral trade that shows the export flows from country i
> (reporter) to country j (partner). For example:
> reporter partner trade
> Albania  Austria  X1
> Albania  Armenia  X2
> .         .        .
> .         .        .
> .         .        .
> Austria  Albania  Xn
> Austria  Armenia  Xn+1
> .         .        .
> .         .        .
> I want to find the total trade flows between the countries.In other words,
> I want to sum the trade from one pair (eg Albania Austria) plus the trade
> from the inversed pair (eg Austria Albania) for around 6000
> observations..Is there any way I could possibly do this?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index