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

st: RE: RE: RE: Replace


From   "Steichen, Thomas J." <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: Replace
Date   Wed, 13 Jul 2005 08:27:14 -0400

Ah, the foibles of untested code... Thanks, Nick, for the catch!

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 Nick Cox
> Sent: Tuesday, July 12, 2005 5:47 PM
> To: [email protected]
> 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 
> [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/
> 

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