Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: Extended Macro function -- dir, and case-sensitivity

From   Max <>
To   statalist <>
Subject   st: Extended Macro function -- dir, and case-sensitivity
Date   Thu, 25 Apr 2013 11:45:54 -0400

Hello Statalist,

I was originally writing for help diagnosing an issue I was having
with the extended macro function -dir-, but I think I've diagnosed the
problem, so instead this e-mail has evolved into a question about why
this issue is happening (and it's kind of a gripe about Stata's
documentation, just to be up-front). The issue is this:

I wanted to get a list of files in a folder and store it in a local
macro, something I've done before. In this case, I wanted a list of
all files ending in "_wDiagnostics," The command I ran was:

local filelist : dir . files "*_wDiagnostics.dta"

But `filelist' came out empty! After a fair amount of playing around,
I discovered that for some reason it worked when I changed the d in
Diagnostics to lowercase (even though all the files have an upper-case
D). Stata's documentation had this to say:
"In Windows only, the respectcase option specifies that dir respect
the case of filenames when performing matches. Unlike other operating
systems, Windows has, by default, case-insensitive filenames.
respectcase is ignored in operating systems other than Windows."

I assume that what the documentation was trying to say is that Windows
treats everything as lower-case, so you should use lower-case or
specify the 'respectcase' option. However, this is not what the
documentation actually says. If Windows ignores case, then shouldn't
it find the files whether I use upper-case or not? The implication of
respectcase is that it should be specified when you don't want to
accidentally include lower-case files in your search for an upper-case
one, or vice versa. But instead it seems like the function is to
actually make the search work. So my question, I guess, is two-fold:
1. If Windows is case-insensitive, why didn't it find my file?
2. Why doesn't Stata explain this more clearly in the documentation?
Or am I totally alone in my interpretation of what the documentation
for this says?

Thank you,
*   For searches and help try:

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