Question

Is it possible to use the command ceil on a time format variable such as 09:31:23? I would like to use ceil to have 09:32:00. I tried to use something similar to round(time,'0:01:00'T) but I want to use ceil since I don't want to round. Use the round will give me 09:31:00. I tried to use ceil instead of round but it doesn't work.

Was it helpful?

Solution

Since SAS time is actually a number of seconds since midnight, CEIL will give you start of next second. To get start of next minute, use INTNX function.

data _null_;
    t='09:31:23.12'T;
    nextsecond=ceil(t);
    nextminute=intnx('minute', t, 1, 'BEGINNING');
    put t= time12.2 nextsecond= time12.2  nextminute= time12.2;
run;

LOG:   t=9:31:23.12 nextsecond=9:31:24.00 nextminute=9:32:00.00
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top