Statalist


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

Re: st: Reshape like problem


From   Pancho Villa <[email protected]>
To   [email protected]
Subject   Re: st: Reshape like problem
Date   Fri, 5 Jun 2009 14:55:17 -0400

On Fri, Jun 5, 2009 at 7:53 AM, Nick Cox<[email protected]> wrote:
> This isn't a reshape-like problem in my book, as no overall change to data structure or shape is needed: you just want new identifier variables.

I stand corrected.

> In the example -id- was just equivalent to observation number. In that circumstance
>
> gen ID_1 = ceil(_n/3)
>
> is an alternative, as are
>
> egen id__1 = seq(), block(3)
> egen id__2 = seq(), to(3)
>
> The first is easy to think about: you are just rounding up 1/3, 2/3, 3/3, 4/3, ... to the next integer.

Yes, this is simple and clever.

> The second two are just wrappers for trickery with -mod()- and -int()-. (I think -egen, seq()- predates -ceil()-.)
>
> Nick

Thanks.
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index