Suppose for example that x is 7.
Then ``x'-1' is evaluated in the standard way,
inside out,
`x' is first evaluated as 7
`7-1' is then evaluated.
This will yield the contents of a macro
if and only if there is a macro with name 7-1.
Otherwise it yields an empty or nill string.
That is not what you want here.
You want to use 7 as part of an expression, _not_
as part of a _name_.
So you want
`=`x' - 1'
Stata sees the = and knows that you want the result
of the evaluation
`x' - 1
which in this example will be 6.
Nick
n.j.cox@durham.ac.uk
Jean Bouyer
> In a loop, I use a local integer variable x that goes from 1 to k. In
> some commands within the loop, I need using the value x-1. I succeed
> in creating another local variable : local x1=`x'-1. But I wonder why
> it didn't work when I used directly ``x'-1'. What is wrong in this
> syntax ?
*
* 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/