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]
st: Interactions between tsset and sort
From
Gordon Hughes <[email protected]>
To
[email protected]
Subject
st: Interactions between tsset and sort
Date
Sat, 12 Feb 2011 07:53:26 +0000
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.
Gordon Hughes
[email protected]
*
* 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/