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.
Asked
Active
Viewed 1,514 times
4

Plug4
- 3,838
- 9
- 51
- 79
1 Answers
7
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

vasja
- 4,732
- 13
- 15
-
Superb! I completely forgotten about the powerful command intnx! Thanks for the insight! Would you know how to ceil/intnx all time variables `09:31:23 09:33:33 09:38:56` to all equal `09:40:00`? – Plug4 Jul 04 '12 at 22:31
-
4AH Nevermind! I can do the following: `nextminute=intnx('minute10', t, 1, 'BEGINNING');` – Plug4 Jul 04 '12 at 22:54