Statalist The Stata Listserver


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

AW: st: Long to wide with monthly frequency


From   "Thomas Erdmann" <[email protected]>
To   <[email protected]>
Subject   AW: st: Long to wide with monthly frequency
Date   Sun, 29 Oct 2006 22:52:53 +0100

Thanks for your suggestion, but I couldnt really duplicate your solution,
so I worked around it (also seems to me like less transformation work
included):

Generated a custom format in Excel which displays the date values as
follows: prfx30Jun2005

Then used the string option be able to use the date

reshape long prfx, i(id) j(strdate) string
generate maindate = date(strdate, "dmy")
format maindate %d
drop strdate


-Tom

 
 

-----Urspr�ngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Kyle Hood
Gesendet: Sonntag, 29. Oktober 2006 16:53
An: [email protected]
Betreff: Re: st: Long to wide with monthly frequency

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/


-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.13/500 - Release Date: 26.10.2006



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