I need to do some date subtraction in my SAS code, but I don't think the INTCK function will work because I would like the answer to present the difference in days:hours:minutes. I could program this out, but I am guessing there is probably a format or function I'm not aware of to accomplish the task.
For example:
Date1 = 01JAN2000 12:00
Date2 = 02JAN2000 14:30
difference = 1:02:30 (i.e. 1 day, 2 hours, 30 minutes)
In this case, if I used INTCK I would need to keep the units in either days or hours, but I can't get the desired format above.
You should be able to use the
%ndirective in a PICTURE format.Note you need to use data type of TIME. WARNING: It doesn't produce proper results when running SAS using DBCS support (for example using Shift-JIS encoding). Or for times that are less than zero. It does work for non-negative values when using single byte character sets, even with UTF-8 encoding.
So instead you could build a function.
and then make a format that calls the function.
So if we test both methods and compare to the values that TIME format produces.
We get: