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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: What is an integer for Stata? |

Date |
Thu, 8 Oct 2009 16:01:29 +0100 |

What you have found is, strictly, an inconsistency and -- at worst -- a small bug. But, like Austin, I don't think it is a serious problem. Introductory users, I guess, will rarely type set obs 1e+4 while more experienced users who tried that would quickly realise that Stata doesn't like that and replace it in one of the ways specified earlier in the thread. So, I think this should go on the developers' to-do list as something to fix, but marked as very low priority. Nick n.j.cox@durham.ac.uk Sergiy Radyakin Thank you Stas, Scott and Austin! I guess Stas has pointed an even more serious problem that confirm integer number 1e4 yields that 1e4 is not integer, while capture assert mod(1e+04,1)==0 yields that it is. which has implications beyond the -set obs- statement. So it does matter how you check for being an integer? Scott's solution is an obvious workaround, but the point is that 1e+04 should not be treated by Stata as an expression, but rather as a single entity - a number. In fact it is treated this way in the input statement: .clear .set obs 1 .input z z 1. 1e+01 2. end .list And note that -input- does not evaluate the values as expressions, e.g. an attempt to input 2+3 as an element of the input statement will cause an error message "cannot be read as a number". So the parser used in the input statement is properly programmed to recognize that "e+" or "e-" after a number is a continuation of the same number, while the regular parser does not do it same. On Thu, Oct 8, 2009 at 8:01 AM, Austin Nichols <austinnichols@gmail.com> wrote: > Sergiy-- > This is such a longstanding property of the -set- command, probably > most Stata users have internalized the behavior, but I suppose it > should be documented in the help file for -set-. Note it applies > equally to set memory, set tracedepth, etc. > > On Thu, Oct 8, 2009 at 5:20 AM, Scott Merryman <scott.merryman@gmail.com> wrote: >> This works: >> . set obs `=1e+04' >> obs was 0, now 10000 >> >> I suppose the 1e+04 has to be evaluated first. On Wed, Oct 7, 2009 at 6:57 PM, Sergiy Radyakin <serjradyakin@gmail.com> wrote: >>> how to explain this? >>> >>> version 10.1 >>> . display 1e+04 >>> 10000 >>> . capture confirm number 1e+04 >>> . display _rc >>> 0 >>> capture assert mod(1e+04,1)==0 >>> . display _rc >>> 0 >>> . clear >>> . set obs 10000 >>> obs was 0, now 10000 >>> . set obs 1e+04 >>> '1e+04' found where integer expected >>> r(198); >>> >>> So what is an integer then? (or what is 1e+04 if not an integer?) * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: What is an integer for Stata?***From:*Sergiy Radyakin <serjradyakin@gmail.com>

**Re: st: What is an integer for Stata?***From:*Scott Merryman <scott.merryman@gmail.com>

**Re: st: What is an integer for Stata?***From:*Austin Nichols <austinnichols@gmail.com>

**Re: st: What is an integer for Stata?***From:*Sergiy Radyakin <serjradyakin@gmail.com>

- Prev by Date:
**Re: RE: st: ARIMA model errors** - Next by Date:
**RE: st: difference between "Spearman" and "pwcorr / correlate"** - Previous by thread:
**Re: st: What is an integer for Stata?** - Next by thread:
**st: problem of running xtlogit, fe** - Index(es):

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