Statalist The Stata Listserver


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

st: RE: If in Mata


From   "Ben Jann" <[email protected]>
To   <[email protected]>
Subject   st: RE: If in Mata
Date   Wed, 12 Apr 2006 09:59:18 +0200

The issue reported by Daniel has also troubled me many 
times. I think the problem is that Mata waits for -else- 
if the -if- construct is used interactively (i.e. outside 
a function). Here's a little illustration:

	. mata: 
	: if (1==1) 1
	> end
	unexpected end of line
	(0 lines skipped)
	r(3000);


	. mata: 
	: if (1==1) 1
	> else 0
	  1
	: end

I see no reason why using -if- without -else- should work 
within a function but not in interactive mode. My suggestion
would be that the problem be fixed by Stata Corp.

ben

> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Daniel Schneider
> Sent: Tuesday, April 11, 2006 10:55 PM
> To: [email protected]
> Subject: st: If in Mata
> 
> I am lost, and I do not know anymore what I am doing wrong with this
> very simple problem. I have been trying to get a very simple if-clause
> to run in Mata, but it hasn't worked at all. I have finally reduced
the
> if-statement to the most simple form:
> 
> mata: if (1==1) results[1,1]
> 
> 
> (results[1,1] should just output a number)
> 
> What I get is
> 
> unexpected end of line
> <istmt> incomplete
> 
> 
> If I do
> 
> . mata: if (1==1) {results[1,1]}
> 
> I get:
> invalid expression
> 
> 
> I have re-read the helpfile a couple of time, but I cannot figure out
> what I am doing wrong. If I go into mata and enter the command by
hand,
> I get an ">" at the beginning of the line suggesting that Mata waits
for
> me to tell it that there is nothing else coming, but I have no clue
how
> to do that.
> 
> Can anyone tell me what I am doing wrong?
> 
> 
> Daniel
> 
> *
> *   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/

*
*   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