Ah, the foibles of untested code... Thanks, Nick, for the catch!
Tom
Thomas J. Steichen
steicht@rjrt.com
----------------------------------------------------------------------------
Facts do not cease to exist because they are ignored. - Aldous Huxley
----------------------------------------------------------------------------
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
> Sent: Tuesday, July 12, 2005 5:47 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: RE: Replace
>
>
> 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
> n.j.cox@durham.ac.uk
>
> 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/
>
-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s),
contains information that may be confidential, protected by the attorney-
client or other legal privileges, and/or proprietary non-public
information. If you are not an intended recipient of this message or an
authorized assistant to an intended recipient, please notify the sender by
replying to this message and then delete it from your system. Use,
dissemination, distribution, or reproduction of this message and/or any of
its attachments (if any) by unintended recipients is not authorized and
may be unlawful.
*
* 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/