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 at the end of May, 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   samuel gyetvay <sam.gyetvay@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Arranging variables across rows
Date   Wed, 27 Jun 2012 13:58:07 -0400

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.

Thank you again,

-Sam
*
*   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