*! version 3.0.1  26mar2003  ESH
*! This version is byable
program define rreplace, nclass byable(onecall)
	version 7
	if _by() {
		local by "by `_byvars', `_byrc0':"
		`by' replace `0'
		tokenize "`0'", parse(" =,")
		local vn `1'
*		note "`vn'": `by' rreplace `"`0'"'
		notes2 `vn': `by' rreplace `"`0'"'
	}
	else {
		tokenize `"`0'"', parse(" =")
		local vn `1'
		replace `0'
*		note "`vn'": rreplace `"`0'"'
		notes2 `vn': rreplace `"`0'"'
	}
end

exit

change
		note "`vn'": rreplace `"`0'"'
to
		notes `vn': rreplace `"`0'"'
to
		notes2 `vn': rreplace `"`0'"'


and
		note "`vn'": `by' rreplace `"`0'"'
to
		notes `vn': `by' rreplace `"`0'"'
to
		notes2 `vn': `by' rreplace `"`0'"'


change
		tokenize `0', parse(" ,")
to
		tokenize `0', parse(" =,")

add
		tokenize `0', parse(" =")

*		di `"1=|`1'|, 2=|`2'|, 3=|`3'|, 4=|`4'|, 5=|`5'|"'
* di `"1=|`1'|, 2=|`2'|, 3=|`3'|, 4=|`4'|, 5=|`5'|, 6=|`6'|, 7=|`7'|, 8=|`8'|"'
Note: version 6 comes out with error with
		tokenize `0', parse(" =,")
(when `0' contains "")
So need to change it by
		tokenize "`0'", parse(" =,")
version 7 can handle this problem (but change it anyway

change to version 7