XtSet
The xtset command declares a panel dataset.
Contents
Usage
. webuse nlswork (National Longitudinal Survey of Young Women, 14-24 years old in 1968) . xtset idcode year Panel variable: idcode (unbalanced) Time variable: year, 68 to 88, but with gaps Delta: 1 unit
. webuse patienttimes . format tod %tc . xtset pid tod Panel variable: pid (unbalanced) Time variable: tod, 03dec2005 06:30:00 to 03dec2005 18:00:00, but with gaps Delta: .001 seconds
Balanced Data
Balanced and unbalanced refers to whether each entity has a measurement in each time period. A common issue is misspecifying the time units (e.g., specifying a wave for panel data that had cohorts added and subtracted across waves).
This issue can be 'corrected' using tsfill to generate missing values for all gaps. The full option will furthermore generate missing values for the leading and trailing 'gaps', i.e. the time periods before and after the entity was actually being measured.
carryforward can be used to populate the gaps with the most recent non-missing value.
webuse nlswork xtset idcode year sort id by id: carryforward birth_yr, generate(birth_yr2) by id: carryforward birth_yr, replace
ipolate can be used to populate the gaps with interpolated values.
Operators
See tsset for the time series operators.