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

st: RE: Replace


From   "Steichen, Thomas J." <[email protected]>
To   <[email protected]>
Subject   st: RE: Replace
Date   Tue, 12 Jul 2005 09:45:18 -0400

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).

Tom

Thomas J. Steichen
[email protected]
----------------------------------------------------------------------------
  Facts do not cease to exist because they are ignored. - Aldous Huxley
----------------------------------------------------------------------------

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Leny Mathew
> Sent: Tuesday, July 12, 2005 9:34 AM
> To: [email protected]
> Subject: st: Replace
> 
> 
> Hi,
>     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.
> 
> Thanks,
> 
> Leny
> 
> 
> 
> 
> 
> *
> *   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/



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