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

st: Mixing global macros with local macros


From   mganz <mganz@hsph.harvard.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Mixing global macros with local macros
Date   Wed, 9 Oct 2002 11:31:25 -0400

Dear Listers,

I'm running Stata 6.0 and I want to set some global 
macros in one program and then access them, in a 
general way in another.

This is what I want to do:

* In the main program I set the globals
global skip1=1
for num 2/10: global skipX=0
do something


* Then in the something.do file I want to repeatedly
* do some regressions and simulations, but only if
* a $skip macro is not equal to 1
local i=1
while (`i'<=10){
	if $skip`i'~=1{
		reg y x w z, if b==`i'
		* etc, etc
	}
	local i=`i'+1
}

But when the while-loop expands the $skip`i' it doesn't 
expand it to $skip1, $skip2, etc.

How can I accomplish this in a generalized and hopefully
not too cumbersome way?

Thanks,
Michael

________________________________________
Michael Ganz, MS, PhD
Assistant Professor
Dept. of Maternal and Child Health
Harvard School of Public Health
mganz@hsph.harvard.edu
http://www.hsph.harvard.edu/faculty/ganz
Ph. 617-432-2382
Fax 617-432-3755

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index