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

Re: st: capturing input file information


From   "Hudes, Estie" <[email protected]>
To   "'Statalist'" <[email protected]>
Subject   Re: st: capturing input file information
Date   Tue, 13 Jan 2004 20:32:58 -0800

Hi again--

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"

--------------- Begin program code ----------
// get input file information
!dir "../rawdata/TNOutcomesqrypedsi.txt" > dir.txt
insheet using dir.txt, noname clear
keep in 4/4
local inputinfo = v1
di "`inputinfo'"

insheet using "../rawdata/TNOutcomesqrypedsi.txt", names clear

< file manipulation >

notes: INPUT DATA INFORMATION "`inputinfo'"
save Outcomes, replace
--------------- End program code ----------


I would appreciate a better solution to this problem.

Thanks,
--Estie Hudes



st: capturing input file information

From	"Hudes, Estie" <[email protected] <mailto:[email protected]>>

To	"'Statalist'" <[email protected]
<mailto:[email protected]>>	
Subject	st: capturing input file information	
Date	Mon, 12 Jan 2004 18:36:23 -0800	

Dear Statalisters--

Is there an easy way to capture information of an input file into a local
macro, so it can be saved as a note with Stata data set? 

I am looking for information similar to that stored in c(filename) and
c(filedate) for a Stata dataset in memory,

For example, I can issue within Stata the command:

. dir "../rawdata/TNOutcomesqrypedsi.txt"

This will display on the screen

 785.9k  12/03/03 13:24  TNOutcomesQryPedsI.txt

I would like to save this information in a local macro, such as `inputinfo'

. insheet using "../4Petra/TNOutcomesqrypedsi.txt", names

(I thought that an macro extended function, with -display-, might do the
trick, but I couldn't get this to work.)

Thanks for your help,
--Estie Hudes

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Estie Sid Hudes, PhD, MPH
Specialist/Statistician
Center for AIDS Prevention Studies &
   Department of Epidemiology & Biostatistics
University of California, San Francisco
74 New Montgomery St., Suite 600
San Francisco, CA 94105
phone: 415/597-9126
fax: 415/597-9194
email: [email protected]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


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


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