Statalist


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

st: making Stata read do-files


From   "Gabi Huiber" <[email protected]>
To   [email protected]
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]_yyyymmdd.do, 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'_YYYYMMDD.do. 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____

clean_report_
13
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)
13

clean_report_dates[13,1]
           c1
 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
DNAreport_
0
invalid syntax
r(198);

end of do-file
r(198);

____and ends here________

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

Best,
Gabi
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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