Statalist


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

st: RE: matrix operation not found


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: matrix operation not found
Date   Wed, 10 Oct 2007 11:00:57 +0100

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/



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