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: 3200 conformability error when writing to stata variable from mata
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: 3200 conformability error when writing to stata variable from mata
Date
Fri, 14 Sep 2012 06:00:44 +0100
In the problematic code you are asking Mata to put a vector of length
20 into a variable with 74 observations. By Mata's rules the two are
not conformable.
It might be suggested that a reasonable default would be that Mata put
this vector in the first 20 observations. Or again, into the last 20
observations. However, defaults such as those are not part of the Mata-
Stata game. You need to be explicit about which observations are to
receive the values in this vector.
Nick
On 14 Sep 2012, at 05:38, Aaron Kirkman <[email protected]>
wrote:
I have a simple piece of code that replicates a -generate- statement
(as an example) to write a new variable to an existing dataset. Under
certain circumstances, however, the code throws a runtime error:
st_store(): 3200 conformability error
<istmt>: - function returned error
This is the code that returns an error:
##
sysuse auto, clear
mata
mata clear
pmg = 1 :: 20
st_addvar("long","pmg")
st_store(.,"pmg",pmg)
end
##
The following code, however, is successful (I removed the views from
the last example because they are not relevant):
##
sysuse auto, clear
mata
mata clear
st_view(mpg=0,.,"mpg")
st_view(weight=0,.,"weight")
pmg=weight:*mpg
st_addvar("long","pmg")
st_store(.,"pmg",pmg)
end
##
As far as I can tell, the matrix -pmg- is of the same form in each
example, although it differs in the number of observations. Both are
column vectors containing only integers, so I'm not sure what is
causing the problem. What is causing the error in the first
*
* 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/