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


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Reshape data from wide to long format
Date   Mon, 24 Sep 2012 14:04:49 +0200

On Mon, Sep 24, 2012 at 1:56 PM, Shittu, Aminu wrote:
> 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

*----------------- begin example -------------------
clear
input species  country  year  month1  month2
1 1 2010 3 5
1 1 2011 1 4
end

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

list
*------------------ end example --------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   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