Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Inexplicable errors when using -reshape long-


From   "Svend Juul" <[email protected]>
To   <[email protected]>
Subject   Re: st: Inexplicable errors when using -reshape long-
Date   Sun, 18 Feb 2007 11:33:10 +0100

Clive Nicholas wrote:
 
Following the example given in -help reshape- when converting one's data from
wide to long format, thus
 
(wide form)                                                   
i     .............. x_ij ...............
id   sex  inc80   inc81   inc82
------------------------------------------
1    0     5000    5500    6000
2    1     2000    2200    3300
3    0     3000    2000    1000
 
(long form)      
i     j             x_ij
id   year   sex    inc 
-------------------------------
1    80      0       5000 
1    81      0       5500 
1    82      0       6000 
2    80      1       2000 
2    81      1       2200 
2    82      1       3300 
3    80      0       3000 
3    81      0       2000 
3    82      0       1000 
 
The help file clearly states that the above is achieved by
. reshape long inc, i(id) j(year)
But I can't reproduce this simple command with my own data, and I _don't_ understand why!
 
. des
Contains data from bepsnew2.dta
  obs:         3,615                          
 vars:            13                          18 Feb 2007 02:54
 size:        65,070 (99.8% of memory free)
-------------------------------------------------------------------------------
              storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------
id              int    %9.0g                  
rsex01          byte   %8.0g       rsex01     Female voter
conle98         byte   %8.0g                  votelc98==conservative
lable98         byte   %8.0g                  votelc98==labour
ldmle98         byte   %8.0g                  votelc98==liberal democrat
othle98         byte   %9.0g                  
conle99         byte   %8.0g                  votelc99==conservative
lable99         byte   %8.0g                  votelc99==labour
ldmle99         byte   %8.0g                  votelc99==liberal democrat
othle99         byte   %9.0g                  
conle00         byte   %8.0g                  votelc00==conservative
lable00         byte   %8.0g                  votelc00==labour
ldmle00         byte   %8.0g                  votelc00==liberal democrat
othle00         byte   %9.0g                  
-------------------------------------------------------------------------------
 
All of the data here (recalculated from the 1997-2001 British Election Panel
Study) - apart from the sex variable - are dummy variables arrayed in wide
format over three waves, with quite a few missings on some of them.
The year is clearly indicated at the end of each variable, apart from the
-id- variable. 
This is a snapshot of the data I need to -reshape-: there are also variables 
indicating survey answers to questions asked on only two waves. Every time I run
-reshape- to convert to long, I get this:
 
. reshape long conle98-othle00, i(id) j(year)
no xij variables found
r(111);
---------------------------------------------------------------------
 
If possible, avoid statements about inexplicability.
 
You should:
   reshape long conle lable ldmle othle , i(id) j(year)
 
Apart from that: I suspect that you will get a problem with the years 98,99,00; 
You might want to rename:
   rename conle00 conle100
to get increasing years.
 
Hope this helps
Svend
________________________________________________________ 
 
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6 
DK-8000 Aarhus C,  Denmark 
Phone, work:  +45 8942 6090 
Phone, home:  +45 8693 7796 
Fax:          +45 8613 1580 
E-mail:       [email protected] 
_________________________________________________________ 

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