Stata 15 help for _xt

Title

[XT] _xt -- Programmer's command to verify that data are xtset properly

Syntax

_xt [, options]

options Description ------------------------------------------------------------------------- trequired caller requires that time variable be set i(panelvar) panel variable t(timevar) time variable -------------------------------------------------------------------------

Description

_xt is used by panel-data commands to verify that the data have been xtset. If a time variable has been set, _xt verifies that it is consistent with the value of delta last recorded by xtset, and the data are sorted by the panel and time variables. If only a panel variable has been set, the data are not sorted.

Options

trequired indicates that the caller needs to know the time variable. By default, _xt assumes that only the panel variable need be known.

i(panelvar) is included for backward compatibility with previous versions of Stata and indicates the panel variable.

t(timevar) is included for backward compatibility with previous versions of Stata and indicates the time variable.

Remarks

The _xt command is for use by panel-data commands to verify that the data have been xtset.

The i() and t() options are provided for backward compatibility with existing xt commands that accept the i() and t() options. Authors of new xt commands should instead require the user to use xtset beforehand, using _xt without those options to verify the integrity of the panel data.

The panel variable is returned in r(ivar), which will be nonempty. The time variable is returned in r(tvar); it will be nonempty if trequired is specified, if t(varname) was specified, or if characteristic _dta[_TStvar] is nonempty. Delta is returned in r(tdelta) if trequired was specified.

Behavior depends on the options specified.

1. Coding

_xt

by itself tells _xt to verify that the data have been xtset by checking whether characteristic _dta[_TSpanel] is nonempty.

2. Coding

_xt, trequired

tells _xt to verify that the data have been xtset by checking whether both characteristics _dta[_TSpanel] and _dta[_TStvar] are nonempty.

Also, _xt verifies that the time variable is consistent, meaning that for each panel, consecutive periods differ by delta units or an integer multiple of delta units. The value of delta is obtained from characteristic _dta[_TSdelta].

After _xt is called, the data will be sorted by the panel and time variables.

3. Coding

_xt, i(panelvar)

or

_xt, i(panelvar) t(timevar)

tells _xt to xtset the data with panelvar or panelvar and timevar, assuming a delta of one. If the data have already been xtset by using different panel or time variables, _xt issues a warning message before re-xtsetting the data. If i() or t() is empty, _xt will examine the dataset characteristics to find the panel or time variable.

Some old panel-data commands looked at characteristics _dta[iis] and _dta[tis] to obtain information about the dataset. If the characteristic _dta[_TSpanel] is empty, _xt checks for the panel variable in _dta[iis] and, if not empty, copies it to _dta[_TSpanel], and similarly for the time variable. However, the use of _dta[iis] and _dta[tis] is considered deprecated and should not be relied upon in new code.


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