Statalist


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

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


From   "Jia Xiangping" <[email protected]>
To   [email protected]
Subject   Re: st: -reshape- with more than one j()?
Date   Fri, 29 Feb 2008 18:48:33 -0500

As both -seed- and -fert- have several categories, Phil's approach is
more efficient. Thanks both of you, Phil and Friedrich.
.

On 2/29/08, Phil Schumm <[email protected]> wrote:
> 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/
>


-- 
Xiangping Jia
*
*   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