[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: recover the dimensions of a panel

From   "Nick Cox" <>
To   <>
Subject   RE: st: recover the dimensions of a panel
Date   Fri, 5 Jun 2009 13:16:13 +0100

qui tab id t 
di r(r)
di r(c) 

will also work if the number of panels and distinct times are both modest. Be careful if the panels are not balanced. 

More generally, check out 

SJ-8-4  dm0042  . . . . . . . . . . . .  Speaking Stata: Distinct observations
        (help distinct if installed)  . . . . . .  N. J. Cox and G. M. Longton
        Q4/08   SJ 8(4):557--568
        shows how to answer questions about distinct observations
        from first principles; provides a convenience command

The software is accessible to all even if you don't have access to the SJ. 


Maarten buis

Is this what you are looking for:

I assume that your panel identifier is called id 
and the time variable t:

// number of periods per person
bys id : gen Nt = _N

// number of person
bys id (t) : gen first = _n == 1
count if first

--- On Fri, 5/6/09, Paulo Regiswrote:
> I am working with a panel, and also need to do some matrix
> operations. The problem is the matrices dimensions depend 
> on the T and N dimensions of the panel. Some times, I have
> to drop obs and the dimension may change so I need to
> revise what are the dimensions of the panel. Things are
> even more complicated if I use a do file.
> Is there any easy way to do this? I usually work with
> -tsset but, unfortunately, i did not find the way to get
> the dimensions of timevar or panelvar.

*   For searches and help try:

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