Home  >>  Archives  >>  Volume 7 Number 4  >>  dm0033

The Stata Journal
Volume 7 Number 4: pp. 571-581



Subscribe to the Stata Journal
cover

Speaking Stata: Counting groups, especially panels

Nicholas J. Cox
Department of Geography
Durham University
Durham City, UK
[email protected]
Abstract.   Counting panels, and more generally groups, is sometimes possible in Stata through a reduction command (e.g., collapse, contract, statsby) that produces a smaller dataset or through a tabulation command. Yet there are also many problems, especially with irregular sets of observations for varying times, that do not yield easily to this approach. This column focuses on techniques for answering such questions while maintaining the same data structure. Especially useful are the Stata commands by: and egen and indicator variables constructed for the purpose. With by: we often exploit the fact that subscripts are defined within group, not within dataset. egen functions are often used to produce group-level statistics. Tagging each group just once ensures that summaries, including counts, are of groups, not individual observations.
Terms of use     View this article (PDF)

View all articles by this author: Nicholas J. Cox

View all articles with these keywords: data management, panels

Download citation: BibTeX  RIS

Download citation and abstract: BibTeX  RIS