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 at the end of May, and its replacement, statalist.org is already up and running.


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

RE: st: Reshape question


From   "Mike Kim" <kalisperos@gmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Reshape question
Date   Sat, 7 May 2011 07:22:57 -0500

Keith Dear,

Thank you, it works! Additional question is... my data contain around 70
different variable names with the same pattern (so, the total variables are
70*5 = 3500). Is there any way I can reshape without listing all 70 variable
names? 

Mike.

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Keith Dear
Sent: Saturday, May 07, 2011 1:02 AM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: Reshape question

reshape long @_gg @_hh @_ii , i(id) j(country) string


On 7 May 2011 14:00, Mike Kim <kalisperos@gmail.com> wrote:
> Dear listers,
>
> My data looks like the following and I want to reshape it from wide to
long.
> There are many more similar variables with the same pattern. Is there any
> easy way to reshape?
>
> id a_gg b_gg c_gg d_gg e_gg  a_hh b_hh c_hh d_hh e_hh  a_ii b_ii c_ii d_ii
> e_ii   ..
> 1     1        5        3        1      2        4        1        1
> 5         1        3      1      1     4      1
> 2    4        1        1        2       1        1        1        2
> 1         1         1      1      5     1      1
> 3    2        1        2        1       1        1        5        1
> 1         3         1      1      1     3      1
> ..
>
> The data format I want is:
>
> id country gg  hh  ii  ..
> 1     a
> 1     b
> 1     c
> 1     d
> 1     e
> 2     a
> 2     b
> 2     c
> 2     d
> 2     e
> 3     a
> 3     b
> 3     c
> 3     d
> 3     e
> ......
>
> Thank you in advance.
> Mike.
>
>
> *
> *   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/
>



-- 
Dr Keith Dear
National Centre for Epidemiology and Population Health
ANU College of Medicine, Biology and Environment
Australian National University
Canberra, ACT 0200 Australia
Phone +61 (02) 6273 2208

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