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

Re: st: Today in a log file


From   David Kantor <[email protected]>
To   [email protected]
Subject   Re: st: Today in a log file
Date   Mon, 03 May 2004 16:59:34 -0400

At 04:28 PM 5/3/2004 -0400, Mart�n Rio wrote:
Is there a way to reference "today"'s date in Stata, where "today" is the
current day based either on the computer's clock or some Stata clock?

The reason why I wonder this is that I frequently run a code that saves its
log in a log folder, and I would like to have each log file called
differently to automatically keep previous logs. It would be nice to be able
to replace the statement:

log using "`path'\logs\programlog.smcl", replace

with:

log using "`path'\logs\progamlog [today].smcl", replace

where [today] would be a function that returns today's date so that it
becomes part of the log's file name.

Other suggestions that achieve the same purpose are also welcome.

Thanks in advance for any help.

Mart�n Rio
Charles River Associates
Washington, DC
phone:  (202) 662-3957
fax:    (202) 662-3910
[...]
What you asked about is the S_DATE global macro. Thus, you might do this:

log using "`path'\logs\progamlog$S_DATE.smcl", replace

But note that $S_DATE evaluates to a string with embedded spaces, such as " 3 May 2004". You may or may not want your file names to have spaces. (I'm not sure it's allowed in all file systems.)

I hope this helps.
-- David


David Kantor
Institute for Policy Studies
Johns Hopkins University
[email protected]
410-516-5404


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