do loop syntax updated??

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
Post Reply
randal_verbrugge
Posts: 16
Joined: Mon Sep 23, 2013 10:43 am

do loop syntax updated??

Post by randal_verbrugge »

Hello!
I am not sure if this is documented, but using {.} seems to work instead of using an end do statement, as in:

do i=1,3 {
dis "i = " i
}

Is this something we can rely upon?

thanks,
Randy
TomDoan
Posts: 7823
Joined: Wed Nov 01, 2006 4:36 pm

Re: do loop syntax updated??

Post by TomDoan »

} has always been synonymous with END. This appears to work because the { (which is synonymous with BEGIN) at the end of the line gets eaten by the parser. On the other hand,

do i=1,3
{
?i
}

(where the { is on a separate line) doesn't work as the } is closing the {} block and not the do loop.

do i=1,3 {
?i
}

works because { doesn't do anything so } is an END to the DO loop.
Post Reply