Statalist


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

st: macro concat


From   Keith Dear <keith.dear@anu.edu.au>
To   statalist@hsphsun2.harvard.edu
Subject   st: macro concat
Date   Sat, 24 May 2008 16:28:39 +1000

Two related questions (or one qn and one wish):

How can I concatenate local macros if their contents are themselves quoted macro names?

loc a \`M1' // macro a contains `M1'
loc b \`M2'
loc c:list a+b // but there is no + operator

I can USUALLY get what I want using the | list operator:
. loc c : list a|b
. mac list _c
_c: `M1' `M2'

But this won't work if local(a) and local(b) happen to be the same. -help macrolists- says:
If you instead want list concatenation, you code
local newlist `"`A' `B'"'
But that won't work here because the contents of my locals will also be evaluated, giving the contents of macros M1 and M2 instead of their quoted names. In my application, M1 M2 (and several more) contain long Windows path names so I don't want to evaluate them (yet).


A wish: it would be neat if macrolist either accepted strings or had a function aslocal(), e.g.

local c // initialise
forval i=1/12 {
local c:list c | aslocal(\`M`i'')
}

or IS there in fact a way to do this in one step?
kd


Dr Keith B.G. Dear
Senior Fellow in Biostatistics
National Centre for Epidemiology and Population Health
Australian National University
Canberra, ACT 0200, Australia
Tel: 02 612 54865, Fax: 02 612 50740
http://nceph.anu.edu.au/Staff_Students/staff_pages/dear.php
CRICOS provider #00120C

http://canberragliding.org/

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