LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (August 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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. > >Data _NULL_; > TESTTIME = DateTime(); > Call Symput( 'Date', Put( TESTTIME, DtTime25.) ); > Put "PNB: Macro symbol DATE populated with " TESTTIME DtTime25.; >Run;

Or, skip the DATA step and just use

%let date=%sysfunc(DateTime(),dttime25.);

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. > >Kind regards > >David > >-----Original Message----- >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of Paul >Sent: Thursday, 2 August 2007 2:49 PM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Can someone tell me what is wrong with this call execute??? > > >I'm trying to create a macro for the following dates > >'2007-07-01 00:00:00.000' >'2007-07-31 23:59:59.999' > >using > >proc format; > picture dttime other='%0y-%0m-%0d %0H:%0M:%0S' (datatype=datetime); >run; > >data _null_ ; > call execute('%let date=%sysfunc(putn(%sysfunc(today()),dttime25.)) ;') ; >run ; >%put &date.; > >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 >were generated. >SYMBOLGEN: Macro variable DATE resolves to 60-01-01 04:49:40 >1728 %put &date.; >60-01-01 04:49:40 > >Can anyone please tell me what is wrong here and why my format is not the >same as what I want??? > >Thank you


Back to: Top of message | Previous page | Main SAS-L page