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

st: Re: capturing input file information


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: Re: capturing input file information
Date   Wed, 14 Jan 2004 14:58:15 -0500

On Jan 14, 2004, at 2:33 AM, Estie wrote:


Here is a temporary solution to the problem I presented yesterday. I am
pretty sure that it can be improved upon, for example, by writing an ado
file. My solution is not very elegant, but it does work.

The solution uses the Stata shell command, and as such only works with
Windows operating system. The shell command creates a file which I named
dir.txt, and then Stata reads the file, selects the line with the file
information, and saves it in a macro to be used later. The macro then
contains information about the last date and time the file was modified, its
size in bytes and it's name
"12/03/2003 01:24p 804,861 TNOutcomesQryPedsI.txt"
This routine should do that:

*! dirinfo cfb 14jan2004
program define dirinfo, rclass
version 8
tempname logname ff
qui log using `logname'.log,replace
dir `0'
qui log close
file open `ff' using "`logname'.log", read
file read `ff' line
file read `ff' line
return local dirinfo "`line'"
end

do "dirinfo auto.dta" (presuming you are in the Stata directory) and then return list.

Kit


*
* 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