Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Long to wide with monthly frequency


From   Kyle Hood <[email protected]>
To   [email protected]
Subject   Re: st: Long to wide with monthly frequency
Date   Sun, 29 Oct 2006 10:52:54 -0500 (EST)

reshape long ---, i(id ) j(year) should give you id year 30.02. 31.03. etc.

then rename all your variables
foreach var of varlist *.*. {
local vn = substr( "`var'" , 1 , 5 ) ;
rename `var' "`vn'"
}

then reshape based on i(id year) j(month)

then rename again and reshape again. (you can use renpfix before the last reshape so that your final variable has a name).



On Sun, 29 Oct 2006, Thomas Erdmann wrote:


Hi,

I have data in the wide format with the id in the first column, then in the
following columns the data on the return index I use, as it is monthly data
I have 12 columns for each year (i.e. the first row reads: id, 31.1.1990,
30.2.1990, 31.03.1990 and so on).

It works out great if I use

reshape long ri, i(id) j(newdate)

when I have only years, but I can't figure out how to get it to work with
the dates. (After reshaping I would like to have a month variable and a year
Variable out of the date part, so I have monthly data.)

thanks for your suggestions
-Tom




*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index