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]

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


From   Sergiy Radyakin <[email protected]>
To   [email protected]
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:
http://en.wikipedia.org/wiki/8.3_filename

For example, having a file "Al`Pia.do" 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`Pia.do
or
do `"R:\Al`Pia.do"'
I have an error 601 file not found. The only working way to execute
this file is to type
do "R:\Al`Pia.do"
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`Pia.do"
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`Pia.do
file R:\Al.do not found
r(601);

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:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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