Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Arranging variables across rows


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Arranging variables across rows
Date   Wed, 27 Jun 2012 19:14:13 +0100

Yes, that sounds all too correct. My error. How about

drop D1-D19

forval i = 1/19 {
           gen D`i' = 0
}

forval j = 1/19 {
              forval k = 1/8 {
                         replace D`j' = 1 if A`j' == B`k' & B`k' < .
              }
}

On Wed, Jun 27, 2012 at 7:07 PM, samuel gyetvay <[email protected]> wrote:
> Sorry, actually, the code is wrong in a different way: it creates a
> dummy variable equal to 1 if any B is equal to A along the same row.
> So in the case
>
> (A1)  (A2)  (A3)  (A4)  (B1)  (B2)  (B3)  (B4)
> 101   102   103  104     .      101   .       .
>
> you get D1, D2, D3, D4 all equal to 1
>
> -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/

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index