Statalist The Stata Listserver


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

Re: st: counting replacements?


From   "Richard Atkins" <[email protected]>
To   <[email protected]>
Subject   Re: st: counting replacements?
Date   Fri, 30 Mar 2007 16:52:14 +0100

recode price 4999=5000
assert `r(N)'==1

Richard Atkins
London School of Hygiene and Tropical Medicine


>>> M Hollis <[email protected]> 30/03/2007 16:36 >>>
I'm setting up a do-file to correct a number of errors
in my dataset.  I'd like to check that each error
correction replaces the value in one and only one
observation. The replace command gives output on how
many values are replaced, but I can't seem to find
where that value is stored, if anywhere.  For example:

sysuse auto
replace price=5000 if price==4099
(1 real change made)

If I could access the 1 in the output, then I could
just use something like:
assert r(changes)==1

but there doesn't seem to be a return list.  I could
do:

count if price==4099
assert r(N)==1
replace price=5000 if price==4099

I'm just wondering if there's a way to get it down to
two lines. 

Thanks,

MH


 
____________________________________________________________________________________
Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/ 
*
*   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/
*
*   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