![]() | ![]() | ![]() | ![]() | ![]() |
The 12 byte datetime field on an IMS log record has this layout:
YYYYDDDFHHMMSSTHmijuAqq$
The first eight bytes of the datetime stamp are identical to the format used in the local time. The remaining 4 are defined as follows:
m - milliseconds, 0 - 9
i - tenths of a millisecond, 0 - 9
j - hundredths of a millisecond, 0 - 9
u - microseconds, 0 - 9
A - attributes of the time value,
qq - quarter-hours of the offset from UTC
$ - decimal sign of the offset
'D' = negative offset
'C' = positive offset
The information for offset is in the last bytes (20D appears to be a minus 5 hours (a minus 20 quarter hours).
Since there is not a SAS informat to read this as a SAS datetime value, a series of logic steps must be implemented to obtain a SAS datetime. Look under FULL CODE tab for the program.
| Product Family | Product | System | SAS Release | |
| Reported | Fixed* | |||
| SAS System | Base SAS | Solaris for x64 | 9.2 TS1M0 | |
| OpenVMS on HP Integrity | 9.2 TS1M0 | |||
| Linux for x64 | 9.2 TS1M0 | |||
| Linux | 9.2 TS1M0 | |||
| HP-UX IPF | 9.2 TS1M0 | |||
| 64-bit Enabled Solaris | 9.2 TS1M0 | |||
| 64-bit Enabled HP-UX | 9.2 TS1M0 | |||
| 64-bit Enabled AIX | 9.2 TS1M0 | |||
| Windows Vista for x64 | 9.2 TS1M0 | |||
| Windows Vista | 9.2 TS1M0 | |||
| Microsoft Windows XP Professional | 9.2 TS1M0 | |||
| Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |||
| Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |||
| Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |||
| Microsoft® Windows® for x64 | 9.2 TS1M0 | |||
| Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |||
| Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |||
| Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |||
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |||
| z/OS | 9.2 TS1M0 | |||
The Julian portion is packed, so you read it in using S370FPD4.
and then feed that into the DATEJUL function to get the date.
The time portion needs to get from a packed representation into
a text representation to be read by the B8601TM informat, which
can handle times with no delimiters. You input it using PK6.,
and put it out as 12. .That can then be informatted using
B8601TM12.6, with 6 digits to the right of the decimal. The
quarter hours are read as packed, multiplied by '00:15:00't to
get the number of seconds. Then we can add them all together
(multiplying date by 86400 to make it a datetime value) to get
the final result. The time as originally seen is 10:36:30.939811,
but the offset is 5 hours prior to GMT so the final time value is
5 hours earlier.
In the example the 'attributes of the time value' is 0. If it
were something else, the code would have to change slightly to
accommodate that.
data _null_;
x='2010251F103630939811020D'x;
date=datejul(input(substr(x,1,4),s370fpd4.));
time=input(put(input(substr(x,5,6),pk6.),12.),b8601tm12.6); put time=;
qhr=input(substr(x,11,2),s370fpd2.)*'00:15:00't;
datetime = date*86400 + time + qhr;
put date=date9. time=time13.6 qhr=time8. datetime=datetime25.6; run;
run;
If the field is read directly via INPUT, you'd have:
input date s370fpd4. time pk6. qhr s370fpd2.;
date = datejul(date);
time = input(put(time,12.),b8601tm12.6);
qhr = qhr*'00:15:00't;
datetime = date*86400 + time + qhr;
We do have the SHRSTAMP informat, which comes close to the
representation of the field. It goes only through hundredths
of seconds, and its year base is 0000 for 1900, so we have to
make a big adjustment.
We still have to read the remaining fractional portion separately.
data _null_;
x='2010251F103630939811020D'x;
datetime=input(substr(x,1,8),shrstamp8.) - '31dec3859:00:00'dt;
frac=input(substr(x,9,2),pk2.6);
qhr=input(substr(x,11,2),s370fpd2.)*'00:15:00't;
datetime + frac + qhr;
put frac= qhr=time8. datetime=datetime25.6;
run;
Result from the first DATA step. date=08SEP2010 time=10:36:30.9398 qhr=-5:00:00 datetime=08SEP2010:05:36:30.939811 Results from using the SHRSTAMP informat. frac=0.009811 qhr=-5:00:00 datetime=08SEP2010:05:36:30.939811
| Type: | Usage Note |
| Priority: |
| Date Modified: | 2010-09-20 13:37:35 |
| Date Created: | 2010-09-16 13:23:29 |




