>. filefilter foo\$bar.txt foo\$bar2.txt, f("a") t("b")
varlist not allowed
r(101);
where the "\" is (presumably) needed to escape the "$", thus
preventing macro expansion.
Yes, the slash does prevent macro expansion. The reason that a
single backslash
doesn't work here lies in the fact that there is already a backslash preceding
the file name. When the first pair of backslashes is encountered,
they collapse
down to a single backslash (there is a backslash escaping a backslash). The
next character to be parsed is the dollar sign, which now has no preceding
backslash since the previous two were already parsed. The necessary solution
requires three backslashes for the Stata parser to correctly interpret the
path. Thus, a correct path would look like:
. filefilter "foo\\\$bar.txt" "foo\\\$bar2.txt", f("a") t("b")
This issue involving escape characters and macro expansion is, unfortunately,
one that you could encounter with any Stata command, not just -filefilter-.