Monday 15 July 2013

time - SAS Date convention and calculation -



time - SAS Date convention and calculation -

i want date calculation. next info type not available date calculation.

data character; length id time1 time2 $ 30; input id $ 1 time1 $ 4-23 time2 $ 28-46; cards; 7 2013-11-07 11:49:28 2014-11-01 10:29:20 6 2014-09-14 07:36:21 2014-11-01 10:29:20 1 2014-10-14 09:36:21 2014-11-01 10:29:20 4 2011-04-14 04:36:21 2014-11-01 10:29:20 8 2012-02-14 17:36:21 2014-11-01 10:29:20 ; run;

what want calculate how many minutes or hours between interval.

data character2; set character; informat datevar1 datevar2 date9.; format datevar1 datevar2 date9.; datevar1 = input(substr(time1,1,10), ymddttm24.); datevar2 = input(substr(time2,1,10), ymddttm24.); /* interval=intck('day',datevar1,datevar2);*/ run;

you can this:

data character; input @1 id $1. @4 date1 yymmdd10. @15 time1 hhmmss10. @27 date2 yymmdd10. @38 time2 hhmmss10.; datetime1 = date1 *24*3600 + time1; datetime2 = date2 *24*3600 + time2; format datetime1 datetime2 datetime.; drop date1 time1 date2 time2; cards; 7 2013-11-07 11:49:28 2014-11-01 10:29:20 6 2014-09-14 07:36:21 2014-11-01 10:29:20 1 2014-10-14 09:36:21 2014-11-01 10:29:20 4 2011-04-14 04:36:21 2014-11-01 10:29:20 8 2012-02-14 17:36:21 2014-11-01 10:29:20 ; run;

date time sas

No comments:

Post a Comment