Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: function el() fails


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: Re: function el() fails
Date   Sat, 16 Aug 2008 07:43:12 -0400

< >
This program works fine. The problem is the evil notion that allows Stata to consider variable abbreviations. I always have the setting

set varabbrev off

and with varabbrev off the program works fine. If you turn it on the program fails with 'type mismatch' on the last statement. Clearly the parser, with varabbrev on, is mistakenly looking around for variables whose names begin with p. This does appear to be a bug, because Stata should be looking for a MATRIX name as the first argument to the el() function. It should not examine the namespace of variables, whether or not their names are abbreviated.

Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


On Aug 16, 2008, at 02:33 , Sergiy wrote:


// ----- BEGIN -------
  sysuse auto

  matrix p=1
  matrix a=p

  matrix dir

  matrix list a
  di a[1,1]
  di el(a,1,1)

  matrix list p
  di p[1,1]
  di el(p,1,1)
// ----- END -------

According to the help file for Stata 9:

el(A,i,j)       the i,j element of A (same as A[i,j])

Note that the program above works for matrix name "a" and not "p".
This made it difficult to identify the problem. Because the problem is
observed for some datasets and not for others.
*
*   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