Convert numeric value into time (millisecond) in SAS

please advise on how to convert the numeric value into time using SAS software. I am using the market depth (TRTH), and the time is shown in numeric. For example, 48600044.

Thanks

Best Answer

  • @cedre.casey

    I understand that you want to interpret value in the "BID_TIM_MS" field. The "_MS" field is a millisecond time field. The field represents the number of milliseconds past midnight GMT. The field is in Integer data format.

    For example the 13:30:0:044 can be converted from 48600044 milliseconds. Below is how the value is generated.

    Hour: 13 * ( 60 * 60 * 1000 ) = 46800000 milliseconds
    Minute: 30 * ( 60 * 1000 ) = 1800000 milliseconds
    Second: 0 * ( 1000 ) = 0 milliseconds
    Millisecond: 44 milliseconds
    Total: 46800000 + 1800000 + 0 + 44 = 48600044 milliseconds.

    To interpret values of the millisecond time field, you can use the following formula.
    int msec = time_ms%1000;
    int seconds = (((int)(time_ms/1000)) % 60);
    int minutes = (((int)(time_ms/60000)) % 60);
    int hours = (((int)(time_ms/3600000)) % 24);

Answers