I'm sorry to return to the well again so soon, but I suspect that
this question (and its answer) might be of interest to others out
there. One of the first things one learns when working with macros
is the difference between
local macname = "mystring"
and
local macname "mystring"
In the first case, "mystring" is evaluated as a string expression
before macro assignment occurs, and thus only the first 80 characters
of mystring (244 for Stata/SE) are assigned to macname. In the
second case, "mystring" is not evaluated as a string expression prior
to assignment, and thus up to 67,784 characters (even more for
Stata/SE) may be assigned to macname.
There is another difference, however, which is a bit easier to forget
-- namely, the first form drops leading spaces while the second does
not. Witness:
. loc foo = " a "
. di "|`foo'|"
|a |
while, in the second case,
. loc foo " a "
. di "|`foo'|"
| a |
Part of the reason I tend to forget this is the fact that the statement:
gen y = " a "
does exactly what you'd expect it to (i.e., it creates a variable
named y in which each observation contains " a ").
Can someone explain why leading spaces are dropped when using the
first form of macro assignment?