Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Unreasonable error "Obs. nos. out of range"


From   Sergiy Radyakin <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Unreasonable error "Obs. nos. out of range"
Date   Mon, 17 Jun 2013 12:38:35 -0400

On Mon, Jun 17, 2013 at 10:21 AM, Stefan Bernhard
<[email protected]> wrote:
> dear statalisters,
>
> i have a piece of looping code over different variables and all
> observations, and an excerpt of the trace shows this:
>
> = if cats[2] == 0 {
>   local bak = 0
>   }
> - noi di as text "bak is `bak'"
> = noi di as text "bak is 0"
> bak is 0
> - replace `var' = 1 in `i'
> = replace cats = 1 in 2
> Obs. nos. out of range
>
>
> This makes no sense at all to me.
>
> In the first line, it successfully uses the value of cats of
> observations number 2 to define the local bak as 0.

No it does not. That code is not executed.
bak is defined elsewhere.
First line is executed successfully because Stata allows you to read
from an observation out-of-range:
sysuse auto
count
display price[0]
display price[100]
Stata does not allow you write to an observation out-of-range.

>
> Few lines later, it acts as if there was no more observations number 2
> and cannot replace the number of cats with 1 in observation number 2.
>
> Why does it say Obs. nos. out of range ?
>
> regards, stefan bernhard,
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index