| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: Using scalars when defining matrices
You should only use single quotes to refer to local macros, not scalars.
Scalars are referred to just as variables are -- so you need to be careful
about naming them. In programming contexts, people often use -tempname- to
create a local macro that can be used to name the scalar (and then requiring
the single quotes). An alternative is to use the scalar() function to make
sure they are evaluated as scalars.
Michael Blasnik
----- Original Message -----
From: "Rachel" <[email protected]>
To: "statalist" <[email protected]>
Sent: Thursday, December 07, 2006 7:48 PM
Subject: st: Using scalars when defining matrices
I'm having trouble with the syntax of matrix define (or input) when
using scalars. When I try the following:
scalar b3=2
matrix input Matrixnew=(1,`b3',`b3',`b3'\ `b3',1,0,0\ `b3',0,1,0\
`b3',0,0,1)
I get a syntax error even though I've put a space in between the
slashes and the scalars (per the manual) to avoid confusion. What am
I doing wrong?
*
* 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/