Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: reading files of certain date.


From   Jens Lauritsen <jl@epidata.dk>
To   statalist@hsphsun2.harvard.edu
Subject   st: reading files of certain date.
Date   Sat, 02 Apr 2005 19:34:29 +0200

I would (in windows) something along these lines:
cd ....../foldername // where your files are

* get the list as suggested yesterday into a file
!erase files.txt
dir parcel.* > files.txt

* then you read the file into stata one variable only having each line:
infix str80 line using files.txt

* then you convert each line into variables for day month and year
* (some minor changes to the syntax probably needed)
generate m = real(substr(line,index(line,"/")-2,1)
generate d = real(substr(line,index(line,"/")+1,1)
generate y = real(substr(line,index(line,"/")+4,1)

* and by combining you get the date of files solved.
generate day = dmy(d,m,y)

keep if day = d(.........) //e.g. d(29mar2005)
... and then some lines to get out only the lines you want.

you could do a small menu system in which you would only enter the date of interest and let the other things depend on that. There are good examples in the manuals. Otherwise enter the date of interest in that one line of the do file.

regards Jens Lauritsen
Denmark


*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index