Create the dttime format to mirror the various dtdate formats.
put dt dtdate.; * yields current date ;
put dt dttime.; * yields current time ;
It seems obvious to me, but perhaps I'm missing a good reason why this format does not exist?
You can use the datepart and timepart functions to return date and time, respectively, from a datetime variable.
Thanks Paul, I'm aware of that.
I'm calling these formats in macro code.
So, currently, I have to do something like (contrived example):
%let MyMvar = %sysfunc(datetime(),dtdate.) %sysfunc(timepart(%sysfunc(datetime()),time.);
Instead, I wish I could do:
%let MyMvar = %sysfunc(datetime(),dtdate.) %sysfunc(datetime(),dttime.);
(Yes, I know I could use date() and time() respectively - it's a contrived example.)
So, as with most things in SAS, There Is More Than One Way To Do It (any Perl programmers here?). And there is a workaround as you have suggested.
I still think the dttime format would be useful, seems to naturally follow from the dt* date formats, and would plug a minor hole in the extensive suite of SAS formats.
I'll be the first to admit this is a low priority suggestion. At the same time, and while not knowing the internals of format code, with the existing timepart code and time format code, I suspect a dttime format would be easy for SAS R&D to create. (But of course this is just conjecture on my part.)
The TIMEAMPMw.d format writes time and datetime values as hours, minutes, and seconds in the form hh:mm:ss.ss with AM or PM.
Thanks @kmw, unfortunately that does not meet my needs. Unless I can get 24 hour time and suppress the AM/PM?
See example above ("Instead, I wish I could do").
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.