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: Balanced panel


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Balanced panel
Date   Thu, 11 Jul 2013 15:05:05 +0100

Check out -fillin-.

[D]     fillin  . . . . . . . . . . . . . . . . . . . . Rectangularize dataset
        (help fillin)

SJ-5-1  dm0011  . . . . . . . . . . . . . .  Stata tip 17: Filling in the gaps
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q1/05   SJ 5(1):135--136                                 (no commands)
        tips for using fillin to fill in gaps in a rectangular
        data structure
Nick
[email protected]


On 11 July 2013 14:47, Estrella Gomez <[email protected]> wrote:
> Dear statalisters
>
> I have a panel that contains exporters, importers and years. Since
> some countries do not trade at all, I would like to generate the zero
> observations for those cases. The command tsfill, full allows me to do
> it for a pair of countries that traded in a given year, but no in the
> rest. It generates zero observations for the years in which two
> countries did not trade, given that those countries traded in some
> year of the sample.
>
> However, I would also like to generate zero flows if two countries did
> not trade at all in any year. For instance, in the following case:
>
> t       exporter        importer        trade
> 2006    AR      CA      1
> 2008    AR      CA      1
> 2006    US      CA      1
> 2007    US      CA      1
> 2008    US      CA      1
> 2006    US      AR      1
> 2007    US      AR      1
> 2008    US      AR      1
> 2006    CA      US      1
> 2007    CA      US      1
> 2008    CA      US      1
> 2006    AT      US      1
> 2007    AT      US      1
> 2008    AT      US      1
>
> tsfill, full would generate:
>
> t       exporter        importer        trade
> 2007    AR      CA      .
>
> but I would also need
>
> t       exporter        importer        trade
> 2006    AR      AT      .
> 2007    AR      AT      .
> 2008    AR      AT      .
>
>
> Any idea?
> Thank you very much,
> Estrella
> *
> *   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/
*
*   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