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: reshape issue

From   Nick Cox <>
Subject   Re: st: reshape issue
Date   Wed, 20 Apr 2011 23:43:16 +0100

I agree with Ada.

Putting this another way: Your data are jointly identified by -caseid-
and -yr-, but the data appear to include nothing other than the
identifiers, so there is nothing to -reshape- as far as Stata is
concerned. Once -yr- has been taken out as an identifier, there is no
-yr- left to act as body of the data. The error message at first sight
doesn't look informative here, but it does show accurately -reshape-'s

There are in effect three essentials here, a data matrix X, i which
explains the rows of the matrix, and j which explains the columns. You
are telling -reshape- that -yr- is both X and j, but once it's used
-yr- as j, there is nothing left.

You seem also confused about whether the variable is -y- or -yr-.


On Wed, Apr 20, 2011 at 9:25 PM, Ada Ma <> wrote:

> what other variables you have in your data?
> There is no point to reshape something with only year and I'd
> And you don't need to convert yr into string as Stata will take care of that.


> I'm having some problems with reshape, probably something really simple.
> I have a long dataset with two variables: caseid yr. I want to reshape to wide,
> so it would be: caseid y1999 y2000 y2001 etc.
> caseid is a string variable, so I've converted yr to a string as well.
> I do:
> reshape wide yr, i(caseid) j(yr) string
> and I get:
> (note: j = 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010)
> variable yr not found
*   For searches and help try:

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