[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: making Stata read do-files

From   "Gabi Huiber" <>
Subject   st: making Stata read do-files
Date   Mon, 14 Apr 2008 19:05:35 -0400

I am having a problem with uppercase letters in file names.

I am trying to impose some version control on a bunch of do-files of
the type [filename], that have been saved weekly with
various changes over the past two years or so.

In the first stage of this job I just want to read their names, then
collect the yyyymmdd part in a matrix. But I am hitting a snag with
files where the alphanumeric part contains uppercase characters. My
code goes like this:

____ code snippet starts here_____

local `k'list: dir "${dofrom}" files "`k'*.do"   // this is the list
of do-files that start with string "`k'_"
local `k'clean: list clean `k'list                 // this strips the
quotes around file names `k'_[...].do
local `k'num: list sizeof `k'clean              // this is the gross
length of that list (in some cases
di "`k'"
di ``k'num'                                            // it includes
all files that start with `k'_, not strictly
                                                          // files of
type `k' in those cases
                                                          // an extra
step is needed, see below)
matrix define `k'dates=J(``k'num',1,0)     // set up empty matrix to
collect dates of do-files

_____and ends here_____________

Now, for cases where this `k' local is like say "clean_report_", all
is well. But when `k' is like "DNAreport_", I get a reading error and
as a result ``k'num', the length of the list of do-files of interes,
becomes zero. See this case:

______snippet of screen output starts here____

number of observations will be reset to 13
Press any key to continue, or Break to abort
obs was 0, now 13
(0 observations deleted)

 r1  20080109
 r2  20080116
 r3  20080123
 r4  20080130
 r5  20080207
 r6  20080213
 r7  20080220
 r8  20080227
 r9  20080305
r10  20080312
r11  20080319
r12  20080326
r13  20080409
invalid syntax

end of do-file

____and ends here________

I am not sure how to get Stata to recognize these file names properly.
I would appreciate any ideas.

*   For searches and help try:

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