Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: RE: Re: Making a unique log file


From   "Donald Spady" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: RE: Re: Making a unique log file
Date   Wed, 26 Apr 2006 09:33:53 -0600

Nick and Michael
  I must blame this on poor eyesight and seeing what I 'expected' to see.
Thanks for the heads up and the explanation.
Don Spady

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: April 26, 2006 4:34 AM
To: [email protected]
Subject: st: RE: RE: Re: Making a unique log file

Michael's code specified curly braces { } in 

${S_DATE} 

and he meant precisely what he wrote. 

In context, the braces make it clear to Stata precisely what
is (and what is not) the name of the global macro whose
contents you want to be inserted at that point. 

Common or garden parentheses ( ) have no such role 
and just get taken literally in this context. Also, 
ordinary algebra in which the choice between { } and ( )
can just be a matter of taste or convenience is no 
guide here, as they are not equivalent in Stata. 

Within 

$(S_DATE) 

Stata sees a $ and gears up for a global macro name 
to follow -- but then the next thing (next token, in 
Stataspeak) is a parenthesis, which cannot be part
of a global macro name. The result is that you just get an empty 
string inserted instead, which is naturally difficult
to see there. (Be assured, it really is there. Or it
really isn't there. Same thing in practice, and 
consult the theologians or philosophers about the
difference in principle.) 

So in this command line the substring 

(S_DATE)

will be taken literally and no macro subsitution will
take place. The rest you know, I think. 

Nick 
[email protected] 

Donald Spady

>   With this all I got was a file named comlog$(S_DATE).txt
> I then tried
> Cmdlog using "D:\statalogs\comlog($S_DATE)" and it worked fine.

Michael Blasnik
 
> Cmdlog using "D:\statalogs\comlog${S_DATE}"

Donald Spady

> >I want to make a command log file using cmdlog, but I want 
> it to be unique
> > every time I begin Stata.  Right now my command is
> >
> > cmdlog using "D:\statalogs\comlog",append
> >
> > I want it to read something like
> > Cmdlog using "D:\statalogs\comlog"+"$S_DATE"
> >
> > or some other unique identifier but every time I try it, 
> the program 
> > aborts
> > when it gets to the '+' sign.  Can someone please tell me 
> how to get this 
> > to
> > work.

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