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

st: RE: replace and variable subscripts


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: replace and variable subscripts
Date   Thu, 10 Mar 2005 13:22:49 -0000

This has been very well explained, but the question 
about documentation remains. It is documented 
e.g. in Roger Newson's tip 

SJ-4-4  dm0008   Stata tip 13: generate and replace use the current sort order
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  R. Newson
        Q4/04   SJ 4(4):484--485                                 (no commands)
        tips for using generate and replace, which use the
        current sort order

and it is mentioned in the FAQs. It is, as far as I know, not explicit 
in the manuals, but I'd welcome a counter-example. 

Another way to appreciate the point is to try to imagine how -sum()- 
would work if Stata did not follow the current sort order. 

Nick 
[email protected] 

Sergey Chernenko
 
> Is the following behavior of -replace- documented anywhere?
> 
> . set obs 10
> obs was 0, now 10
> . gen x = _n
> . replace x = x - x[1]
> (1 real change made)
> . fl
>      +------------+
>      |          x |
>      |------------|
>   1. |          0 |
>   2. |          2 |
>   3. |          3 |
>   4. |          4 |
>   5. |          5 |
>      |------------|
>   6. |          6 |
>   7. |          7 |
>   8. |          8 |
>   9. |          9 |
>  10. |         10 |
>      +------------+
> 
> I would have expected -replace- to subtract 1 from each 
> observation, not
> just the first one.

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