Date: Thu, 2 Aug 2007 08:52:55 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: Can someone tell me what is wrong with this call execute???
On Thu, 2 Aug 2007 15:24:57 +1000, David Johnson <d@DKVJ.BIZ> wrote:
>There are actually a few problems with your statements Paul.
>The first is that you are trying to format a date value (Today() returns a
>date, not a date time) in date time. So, you get a value which is the
>number of days past midnight 1Jan1960 represented as the number of seconds
>past midnight 1Jan1960.
>The second issue is that you are using a Call Execute to generate a SAS
>statement which is overcomplicating the process. Why not just populate the
>macro symbol directly with a Call Symput?
>I would approach the problem in this manner, which gives you the log
>confirmation of the value that you sought, and lets you manipulate the value
>if you wish before it is written to the macro symbol table and the log.
> TESTTIME = DateTime();
> Call Symput( 'Date', Put( TESTTIME, DtTime25.) );
> Put "PNB: Macro symbol DATE populated with " TESTTIME DtTime25.;
Or, skip the DATA step and just use
Notice that %SYSFUNC allows a format as a second argument, so there is no
need for PUTN.
>I rarely create picture formats myself, and have to recheck the
>documentation to be sure of the directives. Thankfully, since SUGI papers
>are published and indexed on the SAS website, I was able to get a paper from
>Andrew Karp http://www2.sas.com/proceedings/sugi31/243-31.pdf to confirm my
>suspicion that your %y directive was wrong. I suspected the correct value
>is %Y which will give you a century value for your year, and Andrews table
>of directives confirm that. I'm sure it is also in the SAS online
>documentation, but I haven't got SAS running here to check at the moment.
>Note also that date times are an integer number of seconds between midnight
>1Jan1960 and the current time. You will not get thousandths of a second
>unless you manipulate the value. If you are testing for value ranges, then
>round down the values to the nearest second with the Floor() function and
>that should work.
>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of Paul
>Sent: Thursday, 2 August 2007 2:49 PM
>Subject: Can someone tell me what is wrong with this call execute???
>I'm trying to create a macro for the following dates
> picture dttime other='%0y-%0m-%0d %0H:%0M:%0S' (datatype=datetime);
>data _null_ ;
> call execute('%let date=%sysfunc(putn(%sysfunc(today()),dttime25.)) ;') ;
>but somehow the log always show
>1725 data _null_ ;
>1726 call execute('%let date=%sysfunc(putn(%sysfunc(today
>()),dttime25.)) ;') ;
>1727 run ;
>NOTE: DATA statement used (Total process time):
> real time 0.01 seconds
> cpu time 0.01 seconds
>NOTE: CALL EXECUTE routine executed successfully, but no SAS statements
>SYMBOLGEN: Macro variable DATE resolves to 60-01-01 04:49:40
>1728 %put &date.;
>Can anyone please tell me what is wrong here and why my format is not the
>same as what I want???