[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: I'll never understand quotes
At 23:09 17-6-2003, you wrote:
Lets take the danger of being only 99,9% correct and explain the main
concept of it:
Hello - could someone please explain why statement #3 below fails if I put
double quotes around `sdir', but statement #2 needs to have double quotes?
1. args gog sdir
2. gen str5 sdir = "`sdir'"
3. save gait_`gog'_`sdir', replace (works)
3. save gait_`gog'_"`sdir'", replace (fails)
Your (single) macro quotes are needed to specify that whatever is in the
local macro sdir is to be inserted at that point. If that local macro would
contain the five characters abcde, things work out as follows.
In #2 you are specifiyng the *contents* of a new string *variable*. That
always needs double quotes in normal syntax (I mean without the local
macro's), like in <gen str5 sdir="abcde"> . The command <gen str5
sdir=abcde> wouldn't work at the command line either.
In #4 you are specifiyng a part of a filename, which -apart from the single
macroquotes- does not need any double quotes in normal syntax, like in
<save filename_alan_abcde, replace>.
At the commandline, <save filename_alan_"abcde", replace> would fail , and
that is exactly how Stata translates your code. It fails because the
character " is not allowed in any filename.
SEO Amsterdam Economics
University of Amsterdam
1018 WB Amsterdam
tel.:+ 31 20 525 1657
fax:+ 31 20 525 1686
A statistician: someone who insists
on being certain about uncertainty
* For searches and help try: