Statalist The Stata Listserver


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

Re: st: RE: Ignoring a reshape error


From   James Fagg <j.fagg@qmul.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Ignoring a reshape error
Date   Thu, 18 May 2006 10:21:02 +0100

Dear Nick,

I am indeed a geographer and am glad to meet another on the list. Incidentally, my supervisor is moving to Durham next year to one of the new health geography posts there so perhaps we will meet at some point as I'm sure I'll be up to Durham.

I'm looking at contextual effects on teenage self-esteem but trying to do it over time, I'm just trying to get the hang of STATA at the moment.

About the repeatedly fixing, I know it seems an odd thing to do, but it is related to my working partly from home and partly at the office and having the raw data on the C:\ drive at both locations. The second determining factor is a bit of a trial and error approach to writing these scrips and not wanting to change anything permanently.

Thanks again for your help and advice, very valuable.

Jamie



Nick Cox wrote:


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 n.j.cox@durham.ac.uk
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/
--

Department of Geography
Queen Mary, University of London
Mile End Rd,
London,
E1 4NS
Tel: 020 7882 5428

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