Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: Compound quotes?


From   dferry <[email protected]>
To   StataList <[email protected]>
Subject   st: Re: Compound quotes?
Date   Wed, 18 Oct 2006 8:46:34 -0400

The macro doesn't work right in my example, below, b/c the local macro, time, is not defined yet. I use the global macro, timeconstraint, in a program with an argument called "time", so I thought that `time' would be defined w/in that program. However, this doesn't seem to be passing into the macro as I intended. The solution is to alter the program get_timeconstraint to take a second argument, time, and call this before trying to use the global macro, timeconstraint. 

On Wed, 18 Oct 2006 8:17:39 -0400, dferry <[email protected]> wrote:
> Dear Statalisters,
> I apologize for the mundane post, but compound quotes always give me
> trouble. I think this is a time to use them, but I can't quite figure out
> how to specify them. I want to write a little program that will specify a
> global macro ($timeconstraint) that contains a reference to a local macro
> (`time') that will be defined in the program in which the global macro
> will be used. As I've written it, below, the local macro (`time') doesn't
> appear if I display the global macro ($timeconstraint). I've tried various
> combinations of compound quotes, but can't seem to get it right. Can
> someone offer help, please?
> 
> capture program drop get_timeconstraint
> program get_timeconstraint
> 
> 	version 9
> 	args runNum
> 
> 	if "`runNum'"=="1" {
> 		global timeconstraint "time>=`time'-12 & time<=`time'"
> 	}
> 
> 	else {;
> 		global timeconstraint "time==`time'"
> 	}
> 
> end
> 
> . get_timeconstraint 1
> 
> . di "$timeconstraint"
> time>=-12 & time<=
> 
> Thank you.
> 
> Sincerely,
> Danielle Ferry


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