Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Arranging variables across rows


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Arranging variables across rows
Date   Wed, 27 Jun 2012 19:04:21 +0100

Have you actually tried my code?

I cycle over all cross-combinations of the A* and B*, so that should
not be a problem.

Also, your word translation is a mistranslation of the code.

Nick

On Wed, Jun 27, 2012 at 6:58 PM, samuel gyetvay <sam.gyetvay@gmail.com> wrote:
> Nick, your "clumsy" code does not solve the problem, which is that A*
> and B* do not always or necessarily line up. So, if you create a dummy
> variable equal to 1 when A'`i' = B`j', several cases would not be
> counted. Consider the case where only the fourth child received
> treatment:
>
> (A1)  (A2)  (A3)  (A4)  (B1)  (B2)  (B3)  (B4)
> 101   102   103   104  104     .       .       .
>
> your code would produce D1, D2, D3, and D4 all equal to 0, despite the
> fourth child having received treatment.
>
> It appears that your first suggestion, followed by
>
> bysort family (person) : gen col = _n
> reshape wide person treated , i(family) j(col)
>
> has worked. I want to perfectly understand each step, and am reading
> through very carefully, referring to definitions of each command used,
> etc. so that I can properly document my work. I will let you know if I
> have any other questions, perhaps in trying to fit the new variable
> "treated" back into the original dataset.
>

*
*   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   |   Site index