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.
Nick
[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:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/