Statalist The Stata Listserver


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

Re: st: Treat $ as text rather than indicator for global macro?


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: Treat $ as text rather than indicator for global macro?
Date   Fri, 1 Jun 2007 09:49:02 -0500

On Jun 1, 2007, at 8:52 AM, Ferry, Danielle ((Exchange)) wrote:
I'm having a little issue which I'm sure one of you wizards will find trivial and can help me with easily, but is currently stumping me.

This works fine:
. di "Balance (\$Bn's)"
Balance ($Bn's)

But this doesn't:
. local Y "Balance (\$Bn's)"
. di "`Y'"
Balance ('s)

How can I make it display correctly in the second instance?

Witness:


. loc Y "Balance (\$Bn's)"

. mac li _Y
_Y: Balance ($Bn's)


which shows that the local macro Y does indeed contain "Balance ($Bn's)"; the problem is that after Y has been expanded in your display command, the $B is then replaced by the contents of the global macro B (which in this case is nothing). To avoid this subsequent expansion, use


. di "`macval(Y)'"
Balance ($Bn's)


instead.


-- Phil

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