At 10:03 AM 3/18/2005 +0000, David Fischer wrote:
Hi all,
I am attempting to create a "while" loop that executes, amongst other
things, a "replace" command on a particular variable. I would like this
loop to continue until the "replace" command cannot make any more changes
to the data. In order to do this I would like to be able to access the
number of (real) changes made by the "replace" command, so that I can say
something like "loop while (number of real changes)!=0". Is there a way
to do this in Stata? I thought there might be an underscore variable
that would do this, but I can't find one.
Thanks!
David Fisher.
Coincidentally, just yesterday, I wrote to Stata Tech Support, asking
about this and suggesting that they provide a returned value. It's
potentially under consideration, but there are some issues involved.
Until then, the only way to correctly do it is ...
gen savedcopy = myvar // possibly with a type inserted after -gen-
replace myvar = whatever...
count if savedcopy != myvar
and test r(N)
--------------------------------------------------------