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: Use of matrix values in generate statements


From   Daniel Feenberg <[email protected]>
To   [email protected]
Subject   Re: st: Use of matrix values in generate statements
Date   Sat, 26 Mar 2011 22:09:06 -0400 (EDT)


On Sun, 27 Mar 2011, Nick Cox wrote:

Kit has given the most important answer: Mata is a much richer
language for handling non-standard problems.


Thanks to all for the suggestions, but the best one came from an offline source.

It turns out that you actually can index into an array. This is not suggested in the programming manual, but a trial of:

  gen int i=flpdyr-1992
  gen int j=filestat
  gen z=stdvals[i,j]

does seem to work, and is quite fast (3 seconds/million records for the last statement).

I think it makes for the clearest code, also. I'd like to keep the code straightforward, so that naive users can modify it. (I include myself in that category, obviously!)

I have looked again at [U]14.9 and do not see any hint of this valuable ability, which perhaps explains why no one mentioned it. In fact, I don't believe any plausible interpretation of language given at numbered paragraphs 1 and 2 on page 173 of the Release 11 user's guide would allow this.

If an index is out of range the value returned is missing, but there is no error, which suggests some thought has gone into this feature.

Again thanks for taking an interest,

Daniel Feenberg
NBER
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index