[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: How to get a macro with content `something'

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: How to get a macro with content `something'
Date   Tue, 26 Jan 2010 17:22:39 -0000

Dereferencing occurs at all levels as soon as you write down one or more
pairs of ` ' to indicate a local macro. It's not a question of peeling
one layer off at a time. If that were so, working with nested macros
would be more tedious. 

Thus although you inserted the text "`something'" inside local macro A,
as soon as you write 


Stata looks inside, sees `something' and dereferences that in turn, so
what you get is no surprise. 

If you don't want dereferencing, don't refer to a local macro (until you
need its contents, that is). 

You can delay dereferencing just once by using a backslash, but that
doesn't wire in lifelong protection. It works just once, as said. 

As I don't recognise your need as one I've felt in 15 or so years of
Stata programming, I am tempted to say you are not missing anything. But
let me ask directly: 

Why do you think you need this? 

[email protected] 

Alex Gamma

although I feel I must be overlooking something big,
despite checking [P] and [U] and the Statalist archives,
I wasn't able to figure out how I can simply get a local
macro A with content `something', but without expanding
`something' (something is a macro, too, that contains,
let's say, foo1 [. loc something foo1]).

I couldn't get it to work using "\".
If I code
. loc A \`something'

I will get, as desired,
. mac list _A
_A:             `something'

But if I use A in code, e.g.
. loc s "`A'" + "foo2"

I get
.mac list _s
_s:              "foo1" + "foo2"
instead of
_s:              `something' + "foo2"

. di "`A'"
instead of

Is what I want impossible or even unnecessary?

*   For searches and help try:

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