Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: constructing an unbalanced panel data set based on existing


From   Arik <[email protected]>
To   [email protected]
Subject   Re: st: RE: constructing an unbalanced panel data set based on existing
Date   Wed, 29 Mar 2006 09:17:14 -0800 (PST)

I guess I should add my name to the top of the list
(of people laughing at themselves) - I have managed to
miss Nick's relevant solution after all... 
Many thanks to you all for your help.
Best, 
Arik

--- n j cox <[email protected]> wrote:

> This example affords amusement at various levels.
> 
> First, only earlier today I posted
> 
> gen length = end - beg + 1
> expand length
> bysort Persnr beg: gen month = beg[1] + _n - 1
> drop length
> 
> as an answer to a question to Anna Manzoni. In
> its main feature, this is the same problem,
> but no one seemed to notice.
> 
> Second, the laugh is also on me. Alex's elegant
> solution underlines that my code was twice as
> long as it should have been, as
> 
> expand end - beg + 1
> bysort Persnr beg: gen month = beg[1] + _n - 1
> 
> would have been enough.
> 
> (That said, a composite id plus year variable
> will not be the way to define a panel dataset.)
> 
> Nick
> [email protected]
> 
> Ronnie Babigumira
> 
>  > Im laughing at myself for what I posted before
> 
> Alex Ogan
> 
>  > expand ((End - Start) + 1)
>  > bysort ID: gen IDyear = string(ID) + string(Start
> + _n - 1)
> 
> Arik
> 
>  > I have a list of observations by unit (firm),
>  > which I would like to transfrom into a panle data
> set,
>  > by year/unit.
>  >
>  > Right now, the first variables of the
> observations
>  > look something like
>  >
>  > ID      Start      End      Industry
>  > 1       1985       1990        3
>  > 2       1988       1991        1
>  > 3       1982       1993        3
>  >
>  > And I'd like them to look like
>  >
>  > IDyear       Industry
>  > 11985            3
>  > 11986            3
>  > 11987            3
>  > 11988            3
>  > 11989            3
>  > 11990            3
>  > 21988            1
>  > 21989            1
>  > 21990            1
>  > 21991            1
>  > 31982            3
>  > 31983            3
>  > ...
>  > 31993            3
>  >
>  > Reshape does not seem to help, as I have a
>  > (unbalnaced) range, rather then a fixed list of
>  > variables. Any ideas, what I can do?
> *
> *   For searches and help try:
> *  
> http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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