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

st: RE: RE: Replace

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Replace
Date   Tue, 12 Jul 2005 22:46:43 +0100

Tom's major point is correct. 

His example won't work, however, 
as -in- requires absolute observation numbers and 
is not compatible with -by-. 

by id: replace temp=temp[6] if _n == 2 

would work. 

[email protected] 

Steichen, Thomas J.
> Simply put, Leny, it doesn't work because it is illegal syntax.
> Stata does not allow references to record numbers on the left 
> of the equals sign.  As the error message indicates, Stata interprets
> the [2] as a possible weight indicator and notes that it is 
> not allowed in a replace command.
> You can, instead, used the -in- feature, such as:
>   by id: replace temp=temp[6] in 2
> to replace the second element of temp (within each group 
> defined by id) 
> by the 6th element of temp (again, within each group defined by id).

Leny Mathew

> >     Thank you Thomas, the code works. I still am curious as 
> > to why the 
> > following doesn't work.
> > 
> > by id: replace temp[2]=temp[6] 
> > 
> > Stata gives me an error that weights are not allowed.

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index