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

st: RE: Mixing global macros with local macros


From   "Steichen, Thomas" <STEICHT@RJRT.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Mixing global macros with local macros
Date   Wed, 9 Oct 2002 11:45:36 -0400

Michael Ganz writes: 

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


Bracket the skip`i' part to force evaluation:

> 	if ${skip`i'} ~= 1 {

Tom
CONFIDENTIALITY NOTE:  This e-mail message, including any attachment(s), contains information that may be confidential, protected by the attorney-client or other legal privileges, and/or proprietary non-public information.  If you are not an intended recipient of this message or an authorized assistant to an intended recipient, please notify the sender by replying to this message and then delete it from your system.  Use, dissemination, distribution, or reproduction of this message and/or any of its attachments (if any) by unintended recipients is not authorized and may be unlawful.




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