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
Gordon Hughes <[email protected]>
To
[email protected]
Subject
re: st: Use of matrix values in generate statements
Date
Sun, 27 Mar 2011 16:46:45 +0100
I am sorry for being a little pernickety about the implications of
this discussion, but I would like to be clear about what is or is not
possible in this respect.
The original observation was that the code:
matrix input stdvalues (3700 6200...\3800 6350...\...
gen stded = stdvalues[year-1992,filestat]
does not work. Dan found that
gen int i = flpdyr-1992
gen int j = filestat
gen stded = stdvals[i,j]
does work and Section 14.9 of my User Guide (Stata 10) says that
gen stded = stdvals[2,3]
should also work.
So one inference is that -generate- can access matrix sub-elements
when either the sub-elements are either (a) constants, or (b)
variables, but not if they are defined as (c) expressions. This
would be odd given the way most of Stata works.
An alternative inference is that the problem lies in the variable
type - i.e. if variables or variable expressions are used to specify
sub-elements they must be of type int (or byte) but not float - and
Dan's second piece of code is required to force the result of the
expression to be of type int.
Can anyone tells us what is the correct inference?
Gordon Hughes
[email protected]
*
* 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/