--- On Mon, 5/10/09, raoul reulen wrote:
> I would like Stata to give me an error message if after
> using the replace command no changes have been made.
> Does the replace command give a return code indicating
> whether or not a replacent has been made?
No, but you could get there from first principle: I can
see two reasons why no values where replaced 1) you
specified a condition and all observations did not meet
that condition, 2) All observations that meet your
condition already have the value that you want to
replace it with. So I would code something like this
(I want to replace the variable `x' with the value one
if `touse' == 1 and the variable `foo' == 1):
*------------- begin example ----------------
local cond `"if `touse' & `foo' == 1"'
capture assert `x' == 1 `cond'
if _rc == 0 {
di as err "some informative error message"
exit 198
}
else {
replace `x' = 1 `cond'
}
*-------------- end example -----------------
Hope this helps,
Maarten
--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany
http://www.maartenbuis.nl
--------------------------
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/