help xtpatternvar 

Generate string variable describing panel patterns


xtpatternvar [if] [in] , generate(newvar)


xtpatternvar generates a string variable holding information on panel patterns in a style similar to the output of xtdescribe. The pattern is a character string, "1" for every time unit that is present in the panel in which each observation is included and "." for every time unit that is not present in that panel. Note that the symbol "." has here nothing to do with missing values.


A panel variable and a time variable must have been previously specified; use xtset.

xtpatternvar will not perform if the maximum length of panel exceeds 244, as then the resulting pattern can not be held in a Stata string variable.

The resulting string variable could impose substantial storage requirements in a large dataset.


generate() specifies the name of a new variable to be generated. This is a required option.


. webuse abdata . xtset . xtpatternvar, gen(pattern) . tab pattern . whatever if strpos(pattern, "11111111")


Nicholas J. Cox, Durham University


This program grew from a Statalist question by Abdul BerÔ. Stephen Jenkins provided encouragement.

Also see

Manual: [XT] xtdescribe