Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Unexpected end of file in mata.


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Unexpected end of file in mata.
Date   Thu, 23 Jan 2014 15:53:31 +0000

The first point here

- I am puzzled to see that mata accepts both (i=1) and (i==1). Because
it is that flexible?
- I don't understand why the command if (i = 1) { reassigns
automatically i = 1 even if i = 2. What is happening here?

can be peeled off. In fact, the question already hints at the answer.

i == 1

is, and is only, a test, whether i == 1, and the result is true or false.

i = 1

is, and is only, an assignment. Stata is happy with

if (i = 1)

which takes place in two steps

i  = 1 (assignment)

if (i)   (logical test).

If you start with

i = 1

and follow with

if(i = 2)

then your assignment i = 2 necessarily overwrites the previous assignment.

Nick
[email protected]


On 23 January 2014 15:44, Amadou DIALLO <[email protected]> wrote:

> I have 2 remarks:
> - I am puzzled to see that mata accepts both (i=1) and (i==1). Because
> it is that flexible?
> - I don't understand why the command if (i = 1) { reassigns
> automatically i = 1 even if i = 2. What is happening here?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index