Statalist The Stata Listserver

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

Re: st: counting replacements?

From   "Richard Atkins" <>
To   <>
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 <> 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

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. 



Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center. 
*   For searches and help try:
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index