Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: -reshape- with more than one j()?


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: -reshape- with more than one j()?
Date   Fri, 29 Feb 2008 15:18:05 -0600

On Fri, Feb 29, 2008 at 2:34 PM, Jia Xiangping <[email protected]> wrote:

 After several collapsing, I have such a data,

 ID      Seed    Fert    x
 1       good    mamure  3
 1       good    chem.   4
 1       bad     chem.   2
 1       bad     manuure 1

 But I need to further collapse to:
 ID   x_good_maure       x_good_chem   x_bad_manure  x_bad_chem

. gen foo = Seed + "_" + subinstr(Fert,".","",.)

. drop Seed Fert

. ren x x_

. reshape wide x_, i(ID) j(foo) string
<output omitted>

. li, ab(14)

     +--------------------------------------------------------------+
     | ID   x_bad_chem   x_bad_manure   x_good_chem   x_good_manure |
     |--------------------------------------------------------------|
  1. |  1            2              1             4               3 |
     +--------------------------------------------------------------+


-- Phil

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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