# Re: st: Mata st_matrix question

 From Carl Nelson To statalist@hsphsun2.harvard.edu Subject Re: st: Mata st_matrix question Date Fri, 16 Mar 2007 09:01:12 -0500 (CDT)

```>
>Carl Nelson <chnelson@uiuc.edu> reports,
>
>> The following stata syntax produced the error that b was not found at the
>> gen command, even though it was listed by mat l
>
>> mata
>>    fh = fopen("demcoeff.mat", "r")
>>    X = fgetmatrix(fh)
>>    fclose(fh)
>>    st_matrix("b", X)
>> end
>> mat l b
>> egen lnp1m = median(lnp1)
>> egen lnp2m = median(lnp2)
>> egen lnp3m = median(lnp3)
>> egen lnp4m = median(lnp4)
>> egen lnp5m = median(lnp5)
>> egen z1m = median(z1)
>> egen z2m = median(z2)
>> egen lnexpm = median(lnexp)
>>
>> gen ap =  \$A_NOT + b[1,1]*lnp1m + b[1,2]*lnp2m + b[1,3]*lnp3m + b[1,4]*lnp4m + (1-b[1,1]-b[1,2]-b[1,3]-b[1,4])*lnp5m
>
>
>I suspect that the error message Carl got was not "b not found" but "+b not
>found".  If I'm right, that happened because global macro A_NOT was
>note defined and thus the last line appeared to Stata as
>
>> gen ap =  + b[1,1]*lnp1m + b[1,2]*lnp2m + b[1,3]*lnp3m + b[1,4]*lnp4m + (1-b[1,1]-b[1,2]-b[1,3]-b[1,4])*lnp5m
>
>Am I right?
>

Yes. Thank you for the quick response. And sorry for my careless error.
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```