Statalist The Stata Listserver


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

st: Re: Using scalars when defining matrices


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: Using scalars when defining matrices
Date   Thu, 07 Dec 2006 19:58:57 -0500

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/



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