Example 9.11 Creating SAS Datetime Values and Computing the Difference between Two Datetime Values


Create a new variable that contains a SAS datetime value by combining SAS date values and SAS time values. Compute the difference in hours between two datetime values.

Example Features

Featured StepDATA step
Featured Step Options and StatementsDHMS, INTCK, and MDY functions

Input Data Set

Data set OCT2009_ORDERS contains order placement and shipment information about eight orders. The orders were placed in October 2009, and only the day of the month was recorded. The shipment date and shipment hour were recorded.


                              order_  order_              ship_
    Obs  customerid  orderid    day    time    ship_date   hour 1 XXV0NW C10761 22 23:04 10/24/2009 7 2 5MY0CJ ...

Get Combining and Modifying SAS® Data Sets: Examples Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.