The macro passing is not right in $skip`i', one work around is:
local i=1
while (`i'<=10){
local tmp skip`i'
if $`tmp'~=1{
.......
-----Original Message-----
From: mganz [mailto:[email protected]]
Sent: Wednesday, October 09, 2002 11:31 AM
To: [email protected]
Subject: st: Mixing global macros with local macros
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
[email protected]
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/
*
* 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/