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

st: RE: The replace function


From   "Steichen, Thomas J." <[email protected]>
To   <[email protected]>
Subject   st: RE: The replace function
Date   Mon, 11 Jul 2005 08:37:57 -0400

Something like the following should work:

  . gen tempgrp = int(_n/4 +.75)
  . bysort tempgrp: replace var = var[_N]
  . drop tempgrp

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: Monday, July 11, 2005 8:28 AM
> To: [email protected]
> Subject: st: The replace function
> 
> 
> Hi,
>     I have a vector variable in which I want to replace the 
> first three 
> values by the fourth value; the fifth, sixth, seventh by the eight 
> value; and so on till the end- the 960th value. This could be 
> done with 
> a loop, but the replace function in stata does not allow me 
> to replace 
> a specific observation in the vector. It allows me to replace the 
> vector as a whole. Does any body know of a way in which the function 
> can be made to replace specific values? Is there any other 
> way of doing 
> this?
> 
> Thank you,
> 
> 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