11-01-2013 10:33 AM
PROC FORMAT with PICTURE and DATETIME directive is a good option, but does not seem to provide a method for displaying the decimal portion of the seconds. Except for Amir's solution, is there a way to get PROC FORMAT to display the decimal portion of the seconds?
An enhancement to Amir's solution (the time. format does not include leading zeroes on the Hour).
char_dt = cat(put(datepart(num_dt),yymmdd10.),' ',translate(put(timepart(num_dt),time12.3),'0',' '));
11-01-2013 12:33 PM
This works fine in 9.3 TS1M2 (it doesn't zero pad properly, for some reason, though). You need the decimal in the used part (and at least in 9.3 it only gives 2 places, not 4).
picture mydt low-high='%Y-%0m-%0d %0H:%0M:%0s' (datatype=datetime);
now = datetime()+.05156;
put now= mydt.4;
11-01-2013 12:57 PM
I am seeing the missing leading zero with SAS 9.3 (TS1M2). I do not have 9.4 to test if it is fixed in that version.
25 data _test_;
26 now = dhms(today(),1,2,3.05156);
27 put now= mydt23.3;
28 put now= mydt19.;
now=2013-11-01 01:02: 3.052
now=2013-11-01 01:02: 3
11-01-2013 01:44 PM
Nope, not fixed (I tested in 9.4). Surprised it hasn't been yet, it's been 3 months since it was reported...
01-27-2017 11:36 AM
I had a lab date like this inside this variable "llab_dt_int"
... so similar to yours, I found this worked - where time is 00:00
attrib blah format=$25.;