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: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 <sam.gyetvay@gmail.com> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index