Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: semicolon in local, under delimit ;
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: semicolon in local, under delimit ;
Date
Thu, 6 Feb 2014 22:34:08 +0000
This recipe shows one technique for building up a local macro with
pieces in " ":
local foo
local f1 just waking up
local f2 stretch and groan
local f3 stuff
local f4 breakfast
forval j = 1/4 {
local foo `" `foo' "`f`j''" "'
}
mac li
_foo: "just waking up" "stretch and groan" "stuff" "breakfast"
_f4: breakfast
_f3: stuff
_f2: stretch and groan
_f1: just waking up
Nick
[email protected]
On 6 February 2014 21:32, David Kantor <[email protected]> wrote:
> I find that if I have...
>
> #delimit ;
>
> local m1 "abc;def";
> disp "`m1'";
>
> -- that works as expected, but...
>
> local m2 `"abc;def"';
> disp "`m2'";
>
> chokes on the -local- command. It appears to stop at the first semicolon,
> and renders an "invalid syntax" error.
> Apparently, the embedded semicolon signals the end of the command.
>
> Notice that this happens with compound quotes, but not with simple quotes.
>
> Does anyone have experience with this? -- a solution?
> I need to use compound quotes because the actual situation has a macro with
> components that have embedded spaces -- so that -foreach- will pick up
> segments of the macro having embedded spaces. Thus, for example,
> local m3 `""first item" "second item""'
> --is constructed so that -foreach- yields two pieces:
> first item
> second item
> --rather than four pieces:
> first
> item
> second
> item
>
> And the real-life application is too big to put on one line, so I use
> #delimit ;.
> It worked fine until I added an item having an embedded semicolon.
>
> I use Stata 10. (I plan to upgrade soon.)
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/