Statalist


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

st: RE: Local with Global macro lists


From   "Nick Cox" <[email protected]>
To   <[email protected]>
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-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Valerie
Orozco
Sent: 05 February 2008 20:23
To: [email protected]
Subject: st: Local with Global macro lists

Hi,

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:
*   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