Bookmark and Share

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: Why do `test' and a`test' make a difference?


From   daniel klein <[email protected]>
To   [email protected]
Subject   Re: st: Why do `test' and a`test' make a difference?
Date   Mon, 11 Feb 2013 12:53:33 +0100

As for Jeph's request for a systematic account of how word lists are
parsed, I think this is explained in the manuals and is more about
macro expansion than lists of words.

When you type

`: word 1 of `test''

Stata sees

`: word 1 of Jeph's Example'

since `: word 1 of Jeph' expands to Jeph, you get

Jephs Example'

When you type

: word 1 of `test'

Stata sees

: word 1 of Jeph's Example

which expands to Jeph's

When you type

`"`:word 1 of `test''"'+"[ ]"+`"`:word 2 of `test''"'

Stata sees

`"`: word 1 of Jeph's Example'"' + "[]" + `"`: word 2 of Jeph's Example'"''

we already coverd the first part of this, so lets take a look on the
second. Since `: word 2 of Jeph' is an empty string teh hole
expression becomes

`"Jephs Example'[]s Example'"'


These outputs might not be what you want, but exactly what you would
expect following Stata's logic of macro expansion.  Thre is nothing
unsensical or mysterious about it.

Best
Daniel
-- 
It's getting tripped up by the apostrophe in test since it's a
character with special meaning. Stata kinda sucks with strings...

Try local test "Jephs Example" and it will be more sensical.

On Sun, Feb 10, 2013 at 10:10 PM, Jeph Herrin <[email protected]> wrote:
> I'd like a systematic account of how word lists are parsed. For instance, I
> have been scratching my head over the output of this:
>
> local test "Jeph's Example"
> local wordA `: word 1 of `test''
> local wordB : word 1 of `test'
> local wordC =`"`:word 1 of `test''"'+"[ ]"+`"`:word 2 of `test''"'
> di "`wordA'"
> di "`wordB'"
> di "`wordC'"
>
> cheers,
> Jeph
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index