An Idea Exchange for SAS software and services

Comments
by Regular Contributor
on ‎02-14-2017 10:35 AM

You can use the datepart and timepart functions to return date and time, respectively, from a datetime variable.

by Super Contributor
on ‎02-14-2017 05:08 PM

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.)

by SAS Employee kmw
on ‎03-09-2017 10:56 AM

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.

by Super Contributor
on ‎03-09-2017 05:35 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").

 

Idea Statuses
Top Liked Authors