Statalist


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

st: Have I discovered a bug in st_isname()?


From   "Newson, Roger B" <[email protected]>
To   statalist <[email protected]>
Subject   st: Have I discovered a bug in st_isname()?
Date   Mon, 1 Jun 2009 12:38:00 +0100

Hello all (especially StataCorp)

I have a query about the Mata function st_isname(), which, according to the online documentation, is built-in. (I use Stata 10.1 under Windows XP, which just informed me, when I typed -update query-, that it is fully up to date in all files.) It seems that st_isname() accepts, "Stata names" with embedded spaces as being valid Stata names. I always understood (based on typing

whelp m1_naming

that a Stata name had to be 1-32 characters long, the first character of which must be un upper-case or lower-case letter or an underscore, and the remaining characters must be upper-case or lower-case letters, underscores, or digits from 0 to 9. However, my own experiments with st_isname() indicate that spaces (" ") have the same status as digits. As in the following output:

**** BEGINNING OF Stata RESULTS - CUT HERE
. mata: st_isname("bacon beans chips spam")
  1

. mata: st_isname("bacon beans chips spam!")
  0

. mata: st_isname("bacon 2beans chips spam")
  1

. mata: st_isname("bacon beans chips spam bacon beans chips spam")
  0

. mata: st_isname("bacon beans chips spam bacon bea")
  1
. mata: st_isname(" bacon beans chips spam")
  0
**** END OF Stata RESULTS - CUT HERE

and in many other examples.

Is this behaviour of st_isname() a bug or a feature? And are there any plans to change it? And should we also use the Mata indexnot() function if we want to know that a "Stata name" is a proper Stata name? I ask because I have been using st_isname() to check strings to be input as new variable names to st_addvar(), and have found that I can create Stata variables with names with embedded blanks that way, and that they cannot always be referred to in Stata afterwards.

Best wishes (and thanks in advance)

Roger


Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected] 
Web page: http://www.imperial.ac.uk/nhli/r.newson/
Departmental Web page:
http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/

Opinions expressed are those of the author, not of the institution.

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



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