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: Interactions between tsset and sort


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Interactions between tsset and sort
Date   Sat, 12 Feb 2011 10:25:35 +0000

Whether StataCorp [not Stata Corp, for delicate but compelling
reasons] should do this is for them to decide, but the case does not
sound very convincing to me. I'd guess the fraction of times something
like this is needed is much less than 5%.

In any case, I have a much better solution for you. Clone -tsset- and
modify it so that it works exactly as you want. Your need is
sufficiently strong that this would be a better solution for you
long-term.

Nick

On Sat, Feb 12, 2011 at 7:53 AM, Gordon Hughes <G.A.Hughes@ed.ac.uk> wrote:
> I would like to raise a point for general discussion and perhaps
> consideration by Stata Corp.  It concerns the way in which --tsset-- sorts a
> panel dataset.  As far as I understand, using --tsset panel time-- is
> equivalent to --sort panel time-- with respect to the sort order of the
> data.  A later sort such as --tsset time panel-- cancels the tsset status of
> the data.
>
> This is the right thing to do in 95% of cases because it ensures that time
> series operators work correctly.  However, there is a class of circumstances
> in which this behaviour has unwanted consequences.  I am dealing with
> spatial panel data for which the natural way to stack panel data corresponds
> to sorting by time, then panel so that spatial correlations between panel
> (spatial) units can be dealt with more easily.  At the same time for
> user-written routines it is still necessary to have the data --tsset-- in
> order to identify the panel and time variables easily.
>
> To get round the problem I use --tsset, noquery-- to identify the panel and
> time variables, then -sort time panel-- and then finally --tsset panel
> time-- at the end of the ado file.  This is ok if everything works but it
> leaves a mess behind if the routine exits with an error.  It would be much
> easier if --tsset-- had an option - e.g. [nosort] - which leaves the sort
> order of the data untouched, but also tells Stata that the data is not time
> series data so that time series operators cannot be used.

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index