ISO 8601 SAS Formats and Informats

SAS Support of the ISO 8601 Standard


Introduction

ISO 8601 is an international standard for the representation of dates and times. The standard defines a large number of alternative representations of dates, times, and time intervals.

The representations can be either in a basic format that has a minimal number of characters or in an extended format that adds characters to enhance human readability. For example, January 3, 2003 can be represented as either 20030103 (basic format) or 2003-01-03 (extended format).

The SAS XML LIBNAME engine supports ISO 8601 date and time representations with several SAS formats and SAS informats.


Elements of the ISO 8601 Standard Not Supported

SAS does not support or does not fully support the ISO 8601 elements listed in the following table:

Elements of the ISO 8601 Standard Not Supported or Not Fully Supported
Element
Category
5.2.1.2 Representations with reduced precision Date
5.2.1.3 Truncated representations Date
5.2.1.4 Expanded representations Date
5.2.2 Ordinal date Date
5.2.3 Week date Date
5.3.1.2 Representations with reduced precision Time
5.3.1.3

Representation of decimal fractions

Fractions are supported only on the seconds field value and use a decimal point delimiter.

Time
5.3.1.4 Truncated representations Time
5.3.1.5 Representation with time designator Time
5.3.2

Midnight

Only the zero hour representation is supported.

Time
5.3.3

Coordinated Universal Time (UTC)

Only full hhmmss forms in either extended or basic format can contain the UTC designator.

Time
5.3.4.1 Difference between local time and Coordinated Universal Time Time
5.3.4.2 Local time and the difference with Coordinated Universal Time Time
5.4.1

Complete representation

Only subitem a) For calendar dates is supported. Subitems b) For ordinal dates and c) For week dates are not supported.

Datetime
5.4.2 Representations other than complete Datetime
5.5 Time-intervals Time
5.6 Recurring time-intervals Time


Understanding Time Zone Processing

The SAS formats and informats that support the ISO 8601 standard read and write time values with and without a time zone indicator. There are specific formats and informats for time zone sensitive and time zone insensitive processing. Note that using a time zone indicator with a time zone insensitive informat or not using a time zone indicator with a time zone sensitive informat is considered an error.

Without a time zone indicator, the context of the value is local time. That is, the value is assumed to be in some local time zone and no conversion or adjustment is made. For example, in the United States in the state of Texas, the value 09:00:00 is 9:00 a.m. Central Standard Time and in the state of North Carolina, the value is 9:00 a.m. Eastern Standard Time. Note that these time values are not equivalent to Coordinated Universal Time (UTC) time values due to the differing time zones.

With a time zone offset present, time zone sensitive informats convert the value to UTC, which is the international time standard. For example, the value 09:00:00-05:00 is converted to 15:00:00, which is 3:00 p.m. With the Z time zone indicator (a special case in the ISO standard), the value is assumed to be expressed in UTC and no adjustment or conversion is made.

CAUTION:
With all time informats, the time zone context is not stored with the value. It is recommended that you do not mix time-based values.

When a time value is read into a variable using a time zone sensitive SAS informat, the value is adjusted to UTC as requested via the time zone indicator, but the time zone context is not stored with the value. When a time value is written using a time zone sensitive SAS format, the value is expressed as UTC with a zero offset value and is not adjusted to or from local time.  [cautionend]

See the example Importing Time Values with a Time Zone.

space
Previous Page | Next Page | Top of Page