Statalist The Stata Listserver


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

RE: st: RE: Ignoring a reshape error


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Ignoring a reshape error
Date   Wed, 17 May 2006 17:35:55 +0100

I agree that error fixes to a dataset should be 
recorded in a script (e.g. .do file) as part of 
an audit trail, and that's standard advice. I didn't and 
wouldn't suggest that that must be 
done interactively, although in practice the need
for fixes is often discovered interactively, and 
then a script is developed from a .log file to 
make the series of changes reproducible. 

Whether you want to make the fixes just once, 
and record them, or to make them repeatedly, 
and record them, is up to you, but the second
seems a little more perverse to me. 

Incidentally, your previous email indicated
a Geography address. You appear to have doubled
the number of geographers currently posting to
this list from the original 1, namely myself. 

Nick 
[email protected] 

Jamie Fagg
 
> Dear Nick,
> 
> Thanks for your help with this. I understand your point about 
> the errors 
> in the dataset, they are errors, but can be resolved interactively.
> 
> However, I want to be able to run the code totally automatically as I 
> have the same raw data in two separate locations and this data may 
> change periodically. Thus I wanted to be able to ensure that 
> any changes 
> that I made were made in the programme and not interactively 
> so that, if 
> I need to, I can go back and re-run the data management part of the 
> programme on a changed raw dataset without worrying that I 
> have missed 
> some early changes out.
 
Nick Cox wrote:

> > I can't see what lies behind this. 
> > 
> > On one interpretation, -reshape- would not
> > proceed because it detected what are in 
> > fact errors in your dataset, which you
> > corrected interactively. Once that is 
> > done once it shouldn't need to be done
> > again. 
> > 
> > There is a -capture- command that eats 
> > an error and allows Stata to proceed. 
> > However, on the face of it, -reshape- 
> > errors are indicative of some problem,
> > either with the data or with your understanding 
> > of it, and I wouldn't go down the road of 
> > trying to automate working around them. 
 
James Fagg
  
> >>I need to reshape from long to wide format, and have the 
> >>following code 
> >>and error.
> >>
> >>reshape wide hid  ypsex yptlkm yptlkf yparg* wave ypest*  , 
> >>i(pid) j(age12)
> >>
> >>//age12 not unique within pid; there are multiple 
> observations at the 
> >>same age12 within pid.Type "reshape error" for a listing of 
> >>the problem 
> >>observations.
> >>
> >>The following code sorts this out so that the reshape command 
> >>works but 
> >>I have to run the program up to the first reshape command and 
> >>then run 
> >>this code and on with the program. My question is, how do I 
> >>write this 
> >>sequence so that the error message is ignored by the program and 
> >>rectified afterwards by the code below automatically? Simply 
> >>replacing 
> >>the relevant values before using any reshape command 
> doesn't seem to 
> >>work, i.e.replace age12...reshape wide..
> >>
> >>reshape error
> >>replace age12 = 13 in 6749
> >>replace age12 = 14 in 6750
> >>replace age12 = 15 in 6751
> >>replace age12 = 12 in 9517
> >>replace age12 = 12 in 10055
> >>replace age12 = 11 in 10055
> >>replace age12 = 12 in 10055
> >>replace age12 = 13 in 10056
> >>replace age12 = 14 in 10057
> >>reshape error
> >>reshape wide hid  ypsex yptlkm yptlkf yparg* wave ypest*  , 
> >>i(pid) j(age12)
> > 

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