DATA Step, Macro, Functions and more

Duration in days

Reply
Contributor
Posts: 47

Duration in days

I have two date column as shown below, I want to create duration in terms of days.

 

BookingdateDeparturedateDuration
21dec15:22:33:582016-01-04 
26dec15:12:25:172015-12-28 
PROC Star
Posts: 7,363

Re: Duration in days

The following would do what you want:

 

data have;
  informat Bookingdate datetime19.;
  informat Departuredate yymmdd10.;
  input Bookingdate Departuredate;
  Duration=Departuredate-datepart(Bookingdate);
  cards;
21dec15:22:33:58 2016-01-04
26dec15:12:25:17 2015-12-28
;

Art, CEO, AnalystFinder.com

Ask a Question
Discussion stats
  • 1 reply
  • 100 views
  • 0 likes
  • 2 in conversation