Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: matrix operation not found


From   "Gao Liu" <[email protected]>
To   [email protected]
Subject   Re: st: RE: matrix operation not found
Date   Wed, 10 Oct 2007 11:17:08 -0400

Thank you, Brendan and Nick,

It turned out that I had a typo with the name of one matrix. Thus, not
all the matrices in the local macro `column' were defined.

Thank you.

Gao



On 10/10/07, Nick Cox <[email protected]> wrote:
> Brendan Halpin sent in one guess. I have another.
>
> Here is your code again, set out according to my own
> style prejudices:
>
> forval svc_year = 2003/2006 {
>        forval svc_month = 1/12 {
>                foreach column in "en_clm_pay_amt pay_amt age" {
>                        if (`svc_year' != 2003 | `svc_month' != 1) {
>                                mat `column' = ///
>                                (`column', `column'_`svc_year'_`svc_month')
>                        }
>                }
>        }
> }
>
> What catches my eye are the "  " in
>
> foreach column in "en_clm_pay_amt pay_amt age"
>
> which are not just decorative, but have syntactic
> significance.
>
> Stata has a rule: " " bind together more strongly than
> spaces separate. Thus, from Stata's point of view,
>
> "en_clm_pay_amt pay_amt age"
>
> is _one_ word, or token, not two. So, remove the " "
> and see whether the code then works.
>
> Nick
> [email protected]
>
> Gao Liu
>
> > I tried to join by columns  some matrix stored from previous tabstat
> > results using the following codes:
> >
> >
> > forval svc_year=2003/2006 {
> >                  forval svc_month=1/12 {
> >
> >                            foreach column in "en_clm_pay_amt
> > pay_amt age" {
> >
> >                                                if
> > (`svc_year'!=2003|`svc_month'!=1) {
> >
> >                                                                   mat
> > `column'=(`column', `column'_`svc_year'_`svc_month')
> >
> >                                                   }
> >
> >                             }
> >
> >                    }
> >
> > }
> >
> > where `column' and `column'_`svc_year'_`svc_month' are matrix and have
> > been given a value earlier.  But when running, an error message pops
> > up, indicating that " matrix operation not found, r(501); ". Can
> > anybody tell me what is the wrong with the code ?
>
> *
> *   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/
>


-- 
#405 Patterson Office Tower

Martin School of Public Administration and Policy

University of Kentucky

Phone: 859-257-5481

Fax:  859-323-1937

[email protected]
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index