Help using Base SAS procedures

Timestamp conversion in SAS

Reply
Regular Contributor
Posts: 173

Timestamp conversion in SAS

Hello everyone,

Does anyone know how to convert a DB2 timestamp value from this:

15JUL1992:14:15:44.00208

to something like this?
1992-07-15:14:15:44.00208

I really appreciate your help!
Super Contributor
Super Contributor
Posts: 3,174

Re: Timestamp conversion in SAS

From the SAS support http://support.sas.com/, using SEARCH facility:

Usage Note 8510: PROC FORMAT with PICTURE statement gives flexibility for DATE, TIME and DATETIME FORMATS

http://support.sas.com/kb/8/510.html


Scott Barry
SBBWorks, Inc.
Regular Contributor
Posts: 173

Re: Timestamp conversion in SAS

Hi Scott,

Thank you so much for the input! I got this instruction from the link you provided:

proc format;
picture dttime other='%0m/%0d/%0y %0H:%0M:%0S'
(datatype=datetime);
run;

It has worked for the most part. But the problem now is the milisecond (in bold print) at the end has been truncated:
This is the data before:
15JUL1992:14:15:44.002087

This is the data after:
1992-07-15-14.15.44

Is there a milisecond symbol I can use in this case?

Thank you !!
Super Contributor
Super Contributor
Posts: 3,174

Re: Timestamp conversion in SAS

I don't believe there is support beyond the second. If you are printing this information, it is possible to use the format in a DATA step PUT function assignment (to generate the date portion) and then concatenate the date with a SAS time-portion variable using the TIME format.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 3 replies
  • 114 views
  • 0 likes
  • 2 in conversation