help for xtpattern

Generate code showing pattern of xt data

xtpattern [if exp] , generate(newvar)


Given a panel data set which has been tsset as such, xtpattern generates a string variable coding panels according to presence or absence of observation at different times. This variable contains information tabulated by xtdes. The same code will be assigned to each observation in a panel. Thus, if there were six times of observation, and a panel was observed at times 1, 2, 3, 4 and 6, all five observations for that panel would be coded "1111.1".

The number of observations in each panel must not exceed 80 (or under Stata/SE, 244).


generate(newvar) specifies the name of a new variable to hold the code. It is a required option.


. tsset id time

. xtdes

. xtpattern, gen(pattern)

. egen tag = tag(id)

. tab pattern if tag


Nicholas J. Cox, University of Durham, U.K. n.j.cox@durham.ac.uk

Also see

On-line: help for xtdes Manual: [R] xtdes