Tuesday, August 9, 2011

Formatting Long and Short Durations With a Picture Format

Two new picture directives are specifically designed for formatting time durations. This allows you to use the FORMAT procedure to create formats to show time durations even if they are particularly long or short periods of time.

Using a picture format for a time duration was somewhat perilous in previous SAS releases, because the time picture directives were oriented toward time of day. If a duration ran more than 24 hours, the picture format would neglect the whole days that had elapsed and report only the fractional days. A time of 5 days, 5 seconds would show up just as 5 seconds.

That is no longer a problem with the %n picture directive, which fills in the previously missing days. A picture such as "%n:%H:%M:%S" gives you the duration in days, hours, minutes, and seconds.

For shorter time periods where fractions of seconds matter, the %s picture directive provides the fractional part of the seconds value, including the decimal point.

No comments:

Post a Comment