Statalist The Stata Listserver

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

st: RE: Problem with graph file

From   "Nick Cox" <>
To   <>
Subject   st: RE: Problem with graph file
Date   Sun, 18 Mar 2007 18:30:24 -0000

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. 


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:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index