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: 3200 conformability error when writing to stata variable from mata


From   Aaron Kirkman <[email protected]>
To   [email protected]
Subject   Re: st: 3200 conformability error when writing to stata variable from mata
Date   Mon, 17 Sep 2012 14:17:19 -0500

That was the problem. I changed my code to use missing values for the
remainder of the observations and that seems to work.

Thank you,
Aaron

On Fri, Sep 14, 2012 at 12:00 AM, Nick Cox <[email protected]> wrote:
> 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/
*
*   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