Statalist The Stata Listserver


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

st: counting replacements?


From   M Hollis <m73hollis_stata@yahoo.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: counting replacements?
Date   Fri, 30 Mar 2007 08:36:15 -0700 (PDT)

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/



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