- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In my SAS (version 9.4M8 for Windows) log, time elapsed (CPU time and real time) is by default displayed as x.xx seconds, i.e. to a precision of 10 milliseconds. In order to profile a program consisting of a large (~300000) number of steps, I've been searching for a way to have time elapsed displayed to the millisecond level (i.e. x.xxx seconds), but haven't had any success so far.
Does anybody know if/how this is possible? Or, if it is not possible, whether the numbers displayed are rounded (e.g. an actual time of 1.236 seconds is displayed as 1.24) or truncated (1.236 seconds displayed as 1.23)?
Thanks for any advice / pointers!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The time displayed for a step does not (IMHO) include the time needed to prepare (fetch the text from the program source) the next step, so don't expect the values to exactly sum up. Particularly with lots of quick steps.
And the time needed for resolving macro code is recorded nowhere at all, only in the total sum for the runtime of a complete SAS session..
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't think so, and I doubt that it makes much difference.
but it is not hard to create your own timers use the DATETIME() function.
For example you could use this macro:
https://github.com/sasutils/macros/blob/master/bench.sas
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ok thanks. Do you by chance have any knowledge concerning the rounding vs. truncation issue I mentioned?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@RANUSER_1337 wrote:
Ok thanks. Do you by chance have any knowledge concerning the rounding vs. truncation issue I mentioned?
If you use a function to determine intervals your SYNTAX should set any limit on rounding or truncation. If you are worried about the default display format then change the format used to display the value. SAS Formats for numeric values will round to fit a specified number of decimal places. So increase the decimal places of the format.
A very brief example you can run:
data example; x='01JAN2025:12:35:41.98765432'dt; put '2 decimal places for seconds' x= datetime32.2; put '8 decimal places for seconds' x= datetime32.8; run;
In almost every appearance question the Format will be involved. Even if you don't assign a format SAS will have a default.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm familiar with SAS formats and how/when to apply them. The issue is precisely that I did not find a way to set the format to display milliseconds for the "real/CPU time" messages automatically issued by SAS e.g. after a data step.
It would be meaningful option in my opinion since it allows to use these out of the box log messages (with desired precision), rather than having to insert custom code to calculate and display the elapsed time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@RANUSER_1337 wrote:
Ok thanks. Do you by chance have any knowledge concerning the rounding vs. truncation issue I mentioned?
I'm surprised milliseconds would matter. And if you want to measure a step with millisecond precision, you'd have to think about things that won't be measured (time to write the log message? time to send the results across the network if using a remote session, etc.)
That said, SAS was written by statisticians. I would think it's safe to assume that they would round the time values rather than truncate them.
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The reason I'm trying to get millisecond precision is in fact to be able to properly account for all elapsed time - when I added up all the "real time x.xx seconds" values in the log, I obtained ~1.5 hours, whereas the overall real time of the program run, as written by SAS to the log upon conclusion of my batch run, was ~2 hours. This is a significant divergence. However, just adding +0.005 seconds to the real time of each of the (as mentioned, ~300000) steps would bring the sum close to 2 hours.
So, if the values are arrived at by rounding, it's fairly safe to attribute the time gap to periods not considered in the times measured by SAS. However, if they arrived at by truncating, it's quite plausible to assume there are no such unmeasured periods.
I hope this clarifies the rationale of my questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I suppose you could try to investigate this through simulation.
Since you already have the core logic in place to run a series of steps, and compare the actual run time to the sum of the reported run time, you could try running a program with 300,000 fast steps, and see how the times compare. Then try maybe 100 very slow steps, and see how the times compare. You also might get different results from running in interactive mode vs batch mode...
You could always ask tech support. Maybe someone will dig through the source code...
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The time displayed for a step does not (IMHO) include the time needed to prepare (fetch the text from the program source) the next step, so don't expect the values to exactly sum up. Particularly with lots of quick steps.
And the time needed for resolving macro code is recorded nowhere at all, only in the total sum for the runtime of a complete SAS session..