Statalist


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

Re: st: Re: recover the dimensions of a panel


From   Austin Nichols <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: recover the dimensions of a panel
Date   Fri, 5 Jun 2009 15:09:35 -0400

But the N and T are not returned by -xtset-; also note that -xtset-
simply calls -tsset- and there is a lot of extraneous code.
The calculation the poster wants might look something like:

webuse grunfeld, clear
qui {
tempvar Ni Nt
loc i:char _dta[iis]
bys `i': g long `Ni'=_n==1
replace `Ni'=sum(`Ni')
loc N= `Ni'[_N]
loc t:char _dta[tis]
bys `t': g long `Nt'=_n==1
replace `Nt'=sum(`Nt')
loc T= `Nt'[_N]
}
di "`N' units over `T' periods"

or, more simply:

webuse grunfeld, clear
qui xtdescribe
di r(N), r(max)

but presumably different patterns of missing data can result in
matrices which are nowhere near NxT; try e.g.

webuse nlswork, clear
xtdescribe
xtreg wks_work age nev_mar, fe
xtdescribe if e(sample)

On Fri, Jun 5, 2009 at 12:12 PM, Martin Weiss <martin.weiss1@gmx.de> wrote:
> Paulo might also like to use -xtset- quietly and look at its return list...
>
> ***
> use http://www.stata-press.com/data/r10/psidextract.dta, clear
> qui xtset
> ret li
> ***
>
> HTH
> Martin
> _______________
> ----- Original Message ----- From: "Paulo Regis"
> <pauloregis.ar@googlemail.com>
> To: <statalist@hsphsun2.harvard.edu>
> Sent: Friday, June 05, 2009 11:05 AM
> Subject: st: recover the dimensions of a panel
>
>
>> Dear all,
>>
>> 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.
>>
>> Cheers
>>
>> Paulo

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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