Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: a question about local macro

From   "Maarten Buis" <>
To   <>
Subject   st: RE: a question about local macro
Date   Fri, 11 Nov 2005 17:55:47 +0100

Yes, local macros are defined locally. For instance if a local `x' is defined in an ado file it only exists while executing that ado file, and will not change or use an local `x' that was defined earlier. The same is true in do files. This is a feature since that way you only have to worry about locals that you defined in your own do or ado file. If you want to use macros outside your do or ado file, you should use a global macro. See the User's Guide section 21.3

Maarten L. Buis
Department of Social Research Methodology 
Vrije Universiteit Amsterdam 
Boelelaan 1081 
1081 HV Amsterdam 
The Netherlands

visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z214 

+31 20 5986715

-----Original Message-----
From: []On Behalf Of Jian Zhang
Sent: vrijdag 11 november 2005 17:48
Subject: st: a question about local macro


I have a question about the local macro.  I could not figure out why and
how to get around it.  Hope that you can help me out.

Here is the question.  In my do file, I have two commands as follows:

local IC="IC412 IC413"
reg y `IC'

The question is that when I run the two commands together
it works.  But I found that if I then re-run the second command without
running the first command,  I thought it should give the same results
since i have already defined the local macro, so I do not need to
redefine it.  It turns out that this time stata treated `IC' as empty.
That means if I want to run the second command,  i always need to run the
two commands together.  Am I correct?  Any explanations? Is there anyway
to get around this?


Jian Zhang  

*   For searches and help try:

*   For searches and help try:

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