Statalist The Stata Listserver


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

st: single-line vs multiple-line -if- command


From   "Zurab Sajaia" <[email protected]>
To   "statalist" <[email protected]>
Subject   st: single-line vs multiple-line -if- command
Date   Fri, 6 Apr 2007 12:45:18 -0400

Dear all,

I encountered a strange behavior -if- and/or macro inline incrementation operators and was wandering what's going on.

Lets consider this example:

local a=1
local b=1

if 0 local a1=`a++'

if 0 {
local b1=`b++'
}

display `a', `b'
2 1

Although both expressions are false an therefore neither a1 nor b1 will be created, `a' is incremented anyways. If we say that two versions of -if- statement are equivalent then I'd expect exactly same outcome no matter what type of commands and operations (like inline macro substitution) is used. Am I confusing something here?

I would appreciate any thoughts about the issue,

Thanks,
Zurab
*
* 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