Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom Datetime Format with Julian Date

Status
Not open for further replies.

ks01

MIS
Aug 11, 2002
110
US
Hi everyone ...

I'm fairly new to SAS and I'm trying to learn on my own.

My company uses the MXG SAS database. According to the schema of this database, I am interested in the following fields:

[tt]Variable Type Len Format Label
JINTTIME Num 8 DATETIME21.2 JOB*INITIATE*TIME
JPRNTIME Num 8 DATETIME21.2 BEGIN OF OUTPUT*PROCESSOR
JSTRTIME Num 8 DATETIME21.2 BEGIN OF EXECUTION*PROCESSOR[/tt]

The output of the DATETIME21.2 format is 17APR2008:17:06:35.97. I would like to convert this format to 108:17:06:35:97 where 108 = Julian date of 17APR2008.

In my DATA statement, I'm doing some other conversions like:

Code:
HOU1 = HOUR(JENDTIME);            
DATE = DATEPART(JSTRTIME);        
DAT1 = DATEPART(JENDTIME);        
QUETIME = JSTRTIME - JRDRTIME;    
MONTH = MONTH(DATEPART(JSTRTIME));

However, I cannot find any built-in SAS formats in the SAS Language Reference Dictionary that will do what I want.

Anyone have any suggestions?

I'm using SAS version 9.1 at my shop.

Thanks!

Kent
 
two options I can think of:

1) use character string, can be sorted and compared in size, but no math operation.
2) use one date variable (in julian format) and one time variable, which would still allow you to math on them. It is a bit twisted when the timestamp of the second date is earlier than the first, in that case, you need to substract the days by one. But it is doable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top