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

st: RE: RE: RE: Correcting the original data set


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: Correcting the original data set
Date   Mon, 20 Jan 2003 17:36:20 -0000

Lee Sieswerda
>
> I agree with Nick C. I think your best bet is to generate a
> do-file from
> your error dataset. However, if like me you are "scripting
> language"-challenged, you can do it using Stata's -file-
> command. This
> little sequence seems to work:
>
> file open myfile using repl_errs.txt, write replace
> forvalues n = 1/(# of obs in error dataset) {
> 	local err_var = err_var[`n']
> 	local correct = correct[`n']
> 	local id = id[`n']
> 	file write myfile "replace `err_var' = `correct' in `id'" _n
> }
> file close myfile
>

Nice!

Or

gen str1 mydo = ""
replace mydo = "replace " + err_var + "=" + correct + " if id==" + id
outsheet mydo using mydo.do, nonames noquote

and after reading in original data

do mydo.do

which I should have thought of earlier...

Nick
[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