Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: simple replace


From   Richard Goldstein <[email protected]>
To   [email protected]
Subject   Re: st: simple replace
Date   Mon, 05 Dec 2005 14:39:54 -0500

I'm a little confused; why not just go -replace z="A"- if you really want 'z' to be all "A"s?

Rich Goldstein

Terra Curtis wrote:


Dear Statalisters,

I think what I have is a simple logic question involving replace.  I can't
seem to find a related question in the list archive.

I have data which looks something like:

x	y	z
-	-	-
A		A
A		A
A	B	A
A	B	A
	B	B
	B	B

I want 'z' to be all "A"s but this involves replacing 'z' with a value of
'x' which is found on a different observation line.  The problem is that the
amount of times 'x' and 'y' overlap throughout the dataset is not
consistent, and therefore I cannot use the x[_n-1] syntax for replacing.  I
think I could use a for-loop but I'm not sure.  Does anyone see how to go
about this?

Thanks very much,
Terra Curtis

*
*   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/


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index