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: Reshape data from wide to long format


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Reshape data from wide to long format
Date   Mon, 24 Sep 2012 13:07:54 +0100

You don't show what you are trying, so that we can explain what you
are getting wrong.

At a guess, you need

reshape long month, i(species country year)
rename month incidence
rename _j month

What is crucial in such problems is (usually) seeing that the
identifier consists of several variables acting jointly.

See also

FAQ     . . . . . . . . . . . . . . . . . . . . . . . .  Problems with reshape
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        12/03   I am having problems with the reshape command. Can
                you give further guidance?
                http://www.stata.com/support/faqs/data/reshape3.html

On Mon, Sep 24, 2012 at 12:56 PM, Shittu, Aminu <ameen_vet@yahoo.com> wrote:

> I am trying some examples from online help but all in vain. My wide dataset looks like this one
>
> Species  Country  Year  month1  month2  month3  month4  month5  month6  month7  month8  month9  month10  month11  month12
>
> I am interested in converting it to a long format like this
>
> Species  Country  Year  month incidence
>
> Please note that the record for each month is a disease incidence.
*
*   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