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

st: RE: Formatted date embedded in log filename


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Formatted date embedded in log filename
Date   Thu, 5 May 2005 19:00:54 +0100

You need to evaluate, not copy. 

To see the difference, do this interactively: 

. local date string(date(c(current_date), "dmy"), "%dN.D.Y")
. di "`date'" 
. local date = string(date(c(current_date), "dmy"), "%dN.D.Y")
. di "`date'" 

The equals sign is crucial here. 

Nick 
n.j.cox@durham.ac.uk 

martin_rio@alum.swarthmore.edu
 
> I usually embed dates in the filenames of my logs. I do so using the
> macro $S_DATE, which, say the date were 1/31/2000, it write it as
> 31jan200. Lately, I've been want to change this format to, 01.31.2000,
> for directory sorting purposes. Using the following expression, I can
> create a macro with the desired format:
> 
> .local date string(date(c(current_date), "dmy"), "%dN.D.Y")
> .di `date'
> 01.31.00
> 
> Where I'm having trouble is with embedding this macro into 
> the filename
> of my log file. The following command complains:
> 
> .log using "logs\cr`date'", replace
> invalid 'dmy'
> r(198);
> 
> Any syntax guru have any ideas?
> 

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