Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: RE: Reshaping data

From   Neil Shephard <>
Subject   Re: st: RE: RE: Reshaping data
Date   Fri, 4 Feb 2011 15:21:08 +0000

On Fri, Feb 4, 2011 at 3:03 PM, DE SOUZA Eric
<> 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.


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

Email -
Website -
Photos -

*   For searches and help try:

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