Statalist


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

st: RE: RE: RE: date function error?


From   "Steichen, Thomas J." <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: RE: RE: date function error?
Date   Thu, 12 Jun 2008 15:16:34 -0400

Version 10 date() no longer uses lowercase "dmy"; you must either use upper case "DMY" or run your program under an earlier version; regardless, adding a version statement to your program is recommended.

Tom

-----------------------------------
Thomas J. Steichen
[email protected]
-----------------------------------

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hoffman, George
Sent: Thursday, June 12, 2008 2:38 PM
To: [email protected]
Subject: st: RE: RE: date function error?

Thank you, Nick.
well, then the problem is somewhere else. my real question is about a
automatic log-creation program that i have run from a profile.do file at
stata startup, which has been malfunctioning.

my intent was to creat a log file with the name mmddhhmm.log, where mmdd
comes from $S_DATE and hhmm comes from $S_TIME.  my program has looked
like this for years, and it has no longer been able to add the mmdd part
because my call to date("$S_DATE","dmy" returns  missing value:
the program is below.
 thanks for helping me out of this rut.

george hoffman


program define autolog
        local logdir=".\logs\"
        local logfile : display  %dND date("$S_DATE","dmy")
substr("$S_TIME",1,2) substr("$S_TIME",4,2)
        local logfile : display "`logdir'" substr("`logfile'",5,.)
".log"
        capture log using `logfile'
        if _rc==602 {
                                while _rc==602 {capture log using
`logfile'}
                                }
        if _rc!=0       {
                                di in red "could not open logfile"
                                error _rc
                                }
        di "----log file:`logfile'----"
end





-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: Thursday, June 12, 2008 11:50
To: [email protected]
Subject: st: RE: date function error?

No Stata error here, just a subtle misunderstanding.

Step 1. Stata substitutes macro names by their contents.

Step 2. -display- sees 12Jun and tries to make sense of it but fails.
12Jun is not a number, nor a variable name, nor a scalar name.

Solution: You need to spell out to Stata that you are dealing with a
string.

. di "$S_DATE"

does that.

Nick
[email protected]

Hoffman, George


i've got stata 10 on win32, and have been troubled by an error in the
date function:

. di $S_DATE
12Jun not found
r(111);


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

-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any
attachment(s), contains information that may be confidential,
protected by the attorney-client or other legal privileges, and/or
proprietary non-public information. If you are not an intended
recipient of this message or an authorized assistant to an intended
recipient, please notify the sender by replying to this message and
then delete it from your system. Use, dissemination, distribution,
or reproduction of this message and/or any of its attachments (if
any) by unintended recipients is not authorized and may be
unlawful.   

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