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: RE: RE: Reshaping data


From   DE SOUZA Eric <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: RE: RE: Reshaping data
Date   Fri, 4 Feb 2011 17:11:55 +0100

Thanks, Neil.

I had got as far as reshape, and effectively obtained v2 to v12, but missed the last step. Stupid of me. Probably the result of too many students knocking on my door today with questions re: their econometrics project.

Eric

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Neil Shephard
Sent: 04 February 2011 16:21
To: [email protected]
Subject: Re: st: RE: RE: Reshaping data

On Fri, Feb 4, 2011 at 3:03 PM, DE SOUZA Eric <[email protected]> wrote:
> My problem is that the first row is -regionid- -2000- -2001- ...
> The years are not preceded by letters such as -var- in your example.
> That's what got me stuck.
> There are several files of this kind, each of which has to be 
> converted into a long variable

So you -insheet- it as usual, and specify the -,header- option, and Stata will look at the header row and go "Hang on a minute, these are illegal variable names, lets call them var2-varN" instead.  You can then reshape as Nick suggested...


> Assuming say -regionid- -var1980- ... -var2009- this is
>
> reshape long var , i(regionid) j(year)

..and to get your years back to what you want you cold then...

replace year = year + 1998

...assuming you've no other variables between the 'regionid' column and the year '2000' column and that there are no missing years (and your brief example suggests this).  If you've got non-continuous years then you might consider using -recode- to recode the default variable names that Stata gives them when -insheet-ing your data to the years they represent.

You can -reshape- the data without any problems in Stata, its then an issue of keeping track of what you actually want each thing to be labelled/named as.

Neil


--
"Truth in science can be defined as the working hypothesis best suited to open the way to the next better one." - Konrad Lorenz

Email - [email protected]
Website - http://kimura.no-ip.org/
Photos - http://www.flickr.com/photos/slackline/

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

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