Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Quotes: Stata's problem? or Windows' problem?

From   Sergiy Radyakin <>
Subject   st: Quotes: Stata's problem? or Windows' problem?
Date   Fri, 12 Mar 2010 13:43:21 -0500

Dear All,

I am experiencing a problem opening some files in Stata (Stata 9, 10,
11, Windows).

In particular, having a single quote ` (same as the opening quote in local's
evaluation) causes Stata to behave incorrectly, even though this character
is valid for DOS names:

For example, having a file "Al`" I can't start it from Windows Explorer
by double-clicking on it with a standard Stata installed according to all the
default settings. Same applies to a dataset with filename "Al`Pia.dta".

While the above were artificial examples to illustrate the problem, the real
problem is experienced by my colleague who has an "`" symbol among the first
letters of his login and is restricted to be able to create files only within
his user-account files (path will always contain "`").

Note also that referring to "short" names conforming to the 8.3 specification
does not help, because the "`" symbol is a valid character in DOS names, and
may (and does) remain in the short directory names.

While fixing the login information might be considered as a solution in this
case, it is not a good solution in general, as the same problem can be
encountered when a filename is generated by an external program and Stata is
called to process the file.

I can't determine for sure whether it is a Windows' or Stata's
problem: the quotes
are removed from the argument in the command line if it does not
contain a space.

Why is this crucial? If I type in Stata:
do R:\Al`
do `"R:\Al`"'
I have an error 601 file not found. The only working way to execute
this file is to type
do "R:\Al`"
with simple (as opposed to compound) double quotes. This is what Stata does when
I use the menu to execute this do-file.

Unfortunately, even if I type the quotes in the command line:
"C:\Program Files (x86)\Stata11\StataMP-64.exe" do "R:\Al`"
the quotes get removed (if the quoted text does not contain spaces) in
the line that Stata
actually executes, according to what gets posted into the output window:
. do R:\Al`
file R:\ not found

While I suspect that this could be the Windows behavior, other OSes may exhibit
similar behavior, and a solution if any, must be within Stata.

So the questions are:

1) what can be done about this situation? (besides advising having a
space in every filename:)

2) why using compound quotes fails in this case? I thought if my
command worked with
simple double quotes, it should always work when I replace them with
compound quotes
and be more robust - tolerate other quotes inside the string. This
example demonstrates that
this is not so, but what rule applies here?

Finally, a small suggestion:
In C# there is an @-instruction, which when it prepends a string
prevents the compiler
from trying to macro-substitute anything in that string. For example:

string first="\r\n"
string second=@"\r\n"
here in the first string will have two characters CR and LF, while the second
string will have four: "\", "r", "\", and "n".

Something similar would be helpful in Stata (I am aware of macval()
and prepending
with \ but it is not as comfortable).

Thank you,
     Sergiy Radyakin
*   For searches and help try:

© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index