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 <>
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 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?


Michael Ganz, MS, PhD
Assistant Professor
Dept. of Maternal and Child Health
Harvard School of Public Health
Ph. 617-432-2382
Fax 617-432-3755

*   For searches and help try:

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