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 - Monthly data


From   Michael Barker <[email protected]>
To   [email protected]
Subject   Re: st: Reshape - Monthly data
Date   Wed, 24 Jul 2013 09:24:55 -0400

If you want to make a month variable after the reshape, as James
mentioned, you can use:

gen monyear2 = montly(monyear, "MY")
format monyear2 %tm

see help date for details on Stata date variables.

Mike


On Wed, Jul 24, 2013 at 4:02 AM, James Beard <[email protected]> wrote:
> David -
>
> You can change your -reshape- command to:
>
>     reshape long gdp gnp, i(id) j(monyear) string
>
> and then convert monyear into a date variable:
>
>     gen int monyear2 = date("01"+monyear,"DMY")
>     format monyear2 %td
>
> (You could even make a Stata "month" variable, if you wanted to).
>
> James.
> On 23 Jul 2013 at 23:43, David Ashcraft wrote:
>
> Date sent:              Tue, 23 Jul 2013 23:43:15 -0700 (PDT)
> From:                   David Ashcraft <[email protected]>
> Subject:                st: Reshape - Monthly data
> To:                     "[email protected]"
> <[email protected]>
> Send reply to:          [email protected]
>
> Hi,
>
> My data is stored in wide format for 15 years as below.
>
> id gdpjan2000 gdpfeb2000 ......gdpdec2012  gnpjan2000 gnp feb2000
> ........gnpdec2012
>
>  Months are three letter and years are four digits. Now I want to
> convert this data into wide on month by month basis. I can do it by
> assuming month and year as string. Is there anyway, I can do it as
> numeric/date variable as I can do for year by using the following:
>
>
> reshape long gdp gnp, i(id) j(year)
>
>
> Any help will be greatly appreciated,
>
>
> David Ashcraft
> PhD Candidate
> Bangor University
> UK
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index