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

st: Re: transforming panel data


From   baum <baum@bc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: transforming panel data
Date   Fri, 27 Sep 2002 08:44:16 -0400

--On Friday, September 27, 2002 2:33 -0400 Paulo wrote:

Please, I need help to change the dataset below (in the wide format) to
long format. Note that the reshape command is not enough to do this
transformation.

            panel     time      schooling   wage
  1.         1          1996       15      3,800
  2.         1          1996       16      3,500
  3.         1          1996       14      3,850
  4.         1          1997       15      3,999
  5.         1          1997       16      4,000
  6.         2          1997       15      4,258
  7.         2          1998       16      4,854
  8.         2          1998       14      4,555
  9.         2          1998       16      4,159
 10.         2          1998       16      4,369
 11.         2          1998       15      4,758
 12          3          1999        .         .
 13          3          1999        .         .
 14          3          1999        .         .
 15          4          2000       17      4,999
 16          4          2000       17      4,870
 17          4          2000       17      4,899
 18          4          2000       16      5,000
 19          4          2000       17      5,409
 20          5          2001       17      5,398
 21          5          2001       17      5,478
 22          5          2001       16      5,369


***************************************************************
 ***** I need the data in this format (with the year controlling the time
series operator) ********************

            panel     time      schooling   wage
  1.         1          1996       15      3,800
  2.         1          1997       16      3,500
  3.         1          1998       14      3,850
  4.         1          1999       15      3,999
  5.         1          2000       16      4,000
  6.         1          2001       15      4,258
  7.         2          1996       16      4,854
Frank replied that the posting did not indicate what Paulo had in mind. That is surely the case; for one thing, both of these are in the long format, so it is not a wide-to-long issue. Secondly, it is very strange that the 6th observation (of 4258) should end up in panel 1, with its year switched from 1997 to 2001, and the year of the seventh obs. should be transformed from 1998 to 1996, etc. unless the issue is that the original data are mislabeled--in which case reshape cannot help, nor can any Stata command, if the data are incorrectly labelled. Paulo should provide a description of what is to be accomplished here, with a small example illustrating the before-after that follows that logic. Rewriting the data to reflect the incorrect coding of observations is not a logical or Stata programming issue.

Kit
________________________________________________________________________
Christopher F Baum, Boston College Economics, Chestnut Hill MA 02467 USA
baum@bc.edu http://fmwww.bc.edu/ec-v/baum.fac.html
*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index