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

RE: st: simple replace


From   "Terra Curtis" <[email protected]>
To   <[email protected]>
Subject   RE: st: simple replace
Date   Mon, 5 Dec 2005 16:12:46 -0500

Sorry, Rich.  I guess I gave an example which was too simplified.  I
actually figured out a different way of doing it because I realized I had an
ID variable which, in our example, looks like:
ID	x	y	z
-	-	-	-
1  	A		A
1 	A		A
1 	A	B	A
1  	A	B	A
1 		B	B
1 		B	B

Then I was able to replace 'z' with 'x' by using -by ID-.  I suppose there
were too many cases to give just one good example of my question, but
luckily I figured out a way to answer it myself.  Thanks for the response,
nonetheless.  Much appreciated.

-Terra

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Richard Goldstein
Sent: Monday, December 05, 2005 2:40 PM
To: [email protected]
Subject: Re: st: simple replace

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/


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