Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Reshape question


From   Radu Ban <[email protected]>
To   <[email protected]>
Subject   Re: st: Reshape question
Date   Wed, 16 Apr 2003 22:54:01 -0400 (EDT)

first you have to rename your countries so that you have a common stub
"serie"

for example you could do (i just learned to this recently on
Statalist, namely from Nick Cox):

local fullnames "Argentina Brazil Colombia..."
local codes "ARG BRA COL..."

local i = 1
foreach x of local fullnames {
	local y : word `i' of `codes'
	rename `x' serie`y'
	local i = `i' + 1
}

*now move on to actual reshaping

reshape long serie, i(date) j(country) string

*note that you have to add the [string] option at the end
*since the suffix is in string format

hope this works, i didnt have time to test it.



-radu ban


On Wed, 16 Apr 2003, Alejandro Ria�o wrote:

> Hello Statalisters, I have the following monthly
> dataset:
>
> date        Argentina     Brazil  Colombia .....
> 01/01/90       x1             y1       z1
> 02/01/90       x2             y2       z2
>    .           .              .        .
>    .           .              .        .
>
> and so on..
>
> where Xi, Yi and Zi are values for a given time-series
>
>
> I'd like this change this dataset into a long format,
> like this:
>
>
> date         Country       Serie
> 01/01/90      ARG           x1
> 02/01/90      ARG           x2
> 01/01/90      BRA           y1
> 02/01/90      BRA           y2
> 01/01/90      COL           z1
> 02/01/90      COL           z2
>
> Thanks your for your help
>
> __________________________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo
> http://search.yahoo.com
> *
> *   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