Statalist


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

RE: st: local macro query


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: local macro query
Date   Mon, 23 Jun 2008 16:48:49 +0100

Sergiy's work-around is clever, but my answer to this is more elementary: as a matter of style, don't define things before you have all the information you need. I'd be interested to know if Daniel has a problem in which that approach is not applicable. 

Nick
n.j.cox@durham.ac.uk 

Sergiy Radyakin

The "\" prevents macro from being evaluated, and thus includes the
reference, not the value into the local being defined. E.g.:

. local test "A \`B' C"
. di `"`test'"'
A  C

// ... later in the program ....

. local B "Zypsel"
. di `"`test'"'
A Zypsel C

On 6/23/08, Höchle, Daniel (MI Switzerland) <daniel.hoechle@rmf.ch> wrote:

> For a program I would like to create several local macros containing strings of type "A `B' C". Later in my program the string "A `B' C" will be evaluated. Unfortunately, however, I don't manage to include single quotes in local macros. I fully understand that
>
>   . local Test "A `B' C"
>   . disp "'Test'"
>   A  C
>
> can't be the solution since local macro B is still empty.

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