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

st: RE: Local with Global macro lists

From   "Nick Cox" <>
To   <>
Subject   st: RE: Local with Global macro lists
Date   Tue, 5 Feb 2008 20:33:12 -0000

I think your problem is that your first reference to $N appears to Stata
to be a reference to $Nvs -- which probably doesn't exist, but Stata
does not care. 

If you have to do this -- and I am not yet convinced that you do, but no

matter -- all you need to do is assign your global to a local just once.

global N = 1            /*here is my global*/
local N "$N" 
local Var`N'vs`N' "(g`N'vs`N' : -("
local one "x + y))"
local Var`N'vs`N'  "`Var`N'vs`N'' `one'"
di "Var`N'vs`N' is  `Var`N'vs`N'' "   

-----Original Message-----
[] On Behalf Of Valerie
Sent: 05 February 2008 20:23
Subject: st: Local with Global macro lists


I have a  problem with macros.
I'm using global macro in some local ones and what I want to obtain
don't work...if someone has an idea.

Example without global macro (which works) :

local Var1vs1 "(g1vs1 : -("
local one "x + y))"
local Var1vs1  "`Var1vs1' `one'"
di "Var1vs1  is `Var1vs1' "   /*it works, I have : Var1vs1  is (g1vs1 :
-( x + y)) */

Example with global macro (doesn't work) :

global N = 1            /*here is my global*/

local Var$Nvs$N "(g${N}vs${N} : -("
local one "x + y))"
local Var${N}vs${N}  "`Var${N}vs${N}' `one'"
di "Var${N}vs${N} is  `Var${N}vs${N}' "   /*Problem I have:Var1vs1 is
x + y)) */

I try to use this sort of program in order to use the nlcom command with
a lot of elements...

*   For searches and help try:

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