Statalist The Stata Listserver


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

Re: st: RE: quotes in macros


From   Keith Dear <[email protected]>
To   [email protected]
Subject   Re: st: RE: quotes in macros
Date   Wed, 26 Jul 2006 09:10:46 +1000

Thanks Maarten, that works well.
Keith

At 06:13 PM 25/7/06, you wrote:
Keith:
You can change the command delimiter to ; by -#delim ;- and after the global command back to enter again with -#delim cr-. So your command would become:

#delim ;
glo list `""rather long filename one" "rather long filename two"
"ridiculously long filename three which takes a whole line"
(etc etc)
"' ;
#delim cr

HTH,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Keith Dear
Sent: dinsdag 25 juli 2006 7:16
To: [email protected]
Subject: st: quotes in macros

I need to create a global macro containing several filenames, each of
which contains a space. This is ok for a short list of short names:

glo list `""file one" "file two" "file three""'

but what I really want is

glo list `""rather long filename one" "rather long filename two" ///
"ridiculously long filename three which takes a whole line" ///
(etc etc) ///
"'

This generates a syntax error, I suppose because quoted strings can't
be split over lines.


Note that in a do-file, the following DOES work:

glo list first_filename_with_no_spaces ///
"after the first, quotes strings with spaces are ok" ///
"file three" "file four"

The problem comes only if the first name needs quoting. So a clumsy
workaround is:

glo list null "file one" ///
etc

foreach file of any $list {
if "`file'"=="null" continue
...
}

But who wants that?
kd

(using Stata 9.2, Win-XP)














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

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

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


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

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