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: RE: How to stack data horizontally?


From   Olivia Bacha <[email protected]>
To   [email protected]
Subject   Re: st: RE: How to stack data horizontally?
Date   Wed, 22 Aug 2012 00:38:45 +0100

Thanks a lot for your reply, David.

I found out the following code does the job:

bysort id: gen j=_n
reshape wide v1-v4, i(id) j(j)

Olivia

2012/8/22 David Radwin <[email protected]>:
> You want to -reshape wide-. Try
>
> . help reshape
>
> for instructions and examples.
>
> David
> --
> David Radwin
> Senior Research Associate
> MPR Associates, Inc.
> 2150 Shattuck Ave., Suite 800
> Berkeley, CA 94704
> Phone: 510-849-4942
> Fax: 510-849-0794
>
> www.mprinc.com
>
>
>> -----Original Message-----
>> From: [email protected] [mailto:owner-
>> [email protected]] On Behalf Of Olivia Bacha
>> Sent: Tuesday, August 21, 2012 4:16 PM
>> To: [email protected]
>> Subject: st: How to stack data horizontally?
>>
>> Hello all,
>>
>> I have the data organized as follows:
>>
>> id    v1      v2      v3      v4
>> 1     1       2       3       4
>> 1     5       6       7       8
>> 1     9       10      11      12
>> 2     13      14      15      16
>> 2     17      18      19      20
>> 2     21      22      23      24
>>
>>
>> And want it to be:
>>
>> v1    v2      v3      v4      v5      v6      v7      v8      v9
> v10     v11     v12
>> 1     2       3       4       5       6       7       8       9       10
> 11      12
>> 13    14      15      16      17      18      19      20      21      22
> 23      24
>>
>> That is, I want to stack it horizontally by  id.
>> Does anyone know how to do that?
>>
>> Thanks in advance.
> *
> *   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