Date: Mon, 17 Aug 2009 09:56:16 -0700
Reply-To: Bob <bob@MYSTICAL.DEMON.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Bob <bob@MYSTICAL.DEMON.CO.UK>
Organization: http://groups.google.com
Subject: Re: Date format
Content-Type: text/plain; charset=ISO-8859-1
On 17 Aug, 14:56, dirk...@GMAIL.COM (Dirk Van Krunckelsven) wrote:
> bobo,
>
> If you want that in a title or footnote, which seems not unlikely, you
> might not need the datstep after all... You can use the Funk in SysFunc,
> like this:
>
> title "Your datetime: %sysfunc(putn(%sysfunc(datetime()),DATETIME13.))";
>
> Cheers,
> Dirk
>
>
>
>
>
> On Mon, 17 Aug 2009 08:48:42 -0500, Joe Matise <snoopy...@GMAIL.COM> wrote:
> >Why the & ?? What are you actually trying to do with the date value?
> >Anyhow, DATETIME() is the correct function for the current DATETIME, today
> ()
> >returns a date, which does not have hours/minutes.
>
> >This will do what you want:
>
> >data _null_;
> >tdy_Date = datetime();
> >format tdy_date DATETIME13.;
> >put tdy_date=;
> >run;
>
> >but it's up to you to use tdy_Date, obviously in a _null_ step it's not
> >going anywhere without further code.
>
> >-Joe
> >On Mon, Aug 17, 2009 at 7:25 AM, Box666 <b...@mystical.demon.co.uk> wrote:
>
> >> I am trying to format todays date as date hours mins which i believe
> >> is "datetime13" but i cannot seems to correctly locate in in the code.
>
> >> data _null_;
> >> tdy_date = (today());
> >> /* format &tdy_date. datetime13.;*/
> >> run;
>
> >> with thanks
>
> >> Bob- Hide quoted text -
>
> - Show quoted text -
i am trying to use it to set a date macro
data _null_;
tdy_date = datetime();
format &tdy_date. DATETIME13.;
s_date = intnx('month',today(),-1);
e_date = intnx('month',today(),-1,'E');
call symput('s_date',put(s_date,tera_dt.));
call symput('e_date',put(e_date,tera_dt.));
call symput('tdy_date',put(tdy_date,tera_dt.));
run;
%syslput s_date=&s_date;
%syslput e_date=&e_date;
%syslput tdy_date=&tdy_date;
%put &s_date &e_date &tdy_date;
although it works fine as
data _null_;
tdy_Date = datetime();
format tdy_date DATETIME13.;
put tdy_date=;
run;
When used as above it ERRORs as
560 data _null_;
561 tdy_date = datetime();
SYMBOLGEN: Macro variable TDY_DATE resolves to ERROR
562 format &tdy_date. DATETIME13.;
563
564 s_date = intnx('month',today(),-1);
565 e_date = intnx('month',today(),-1,'E');
566 call symput('s_date',put(s_date,tera_dt.));
567 call symput('e_date',put(e_date,tera_dt.));
568 call symput('tdy_date',put(tdy_date,tera_dt.));
569 run;
NOTE: Variable ERROR is uninitialized.
NOTE: DATA statement used:
real time 0.00 seconds
cpu time 0.00 seconds
SYMBOLGEN: Macro variable S_DATE resolves to '2009-07-01'
570 %syslput s_date=&s_date;
571 %syslput e_date=&e_date;
SYMBOLGEN: Macro variable E_DATE resolves to '2009-07-31'
572 %syslput tdy_date=&tdy_date;
SYMBOLGEN: Macro variable TDY_DATE resolves to ERROR
573 %put &s_date &e_date &tdy_date;
SYMBOLGEN: Macro variable S_DATE resolves to '2009-07-01'
SYMBOLGEN: Macro variable E_DATE resolves to '2009-07-31'
SYMBOLGEN: Macro variable TDY_DATE resolves to ERROR
'2009-07-01' '2009-07-31' ERROR
|