From: db on
Hi, I have a variable called Time with following format and would like
to extract hour:time only so I can group by hour_time.
Could you tell me how to extract hour and time from this Time
variable ? Thanks

Time
23:59:58.345
23:59:59.234
0:00:00.306
0:00:00.373
0:00:00.373
..
..
..
01:00:00.765


From: db on
Hi, I have a variable called Time with following format and would like
to extract hour:min only so I can group by hour_min.
Could you tell me how to extract hour and min from this Time
variable ? Thanks

Time
23:59:58.345
23:59:59.234
0:00:00.306
0:00:00.373
0:00:00.373
..
..
..
01:00:00.765
From: Joe Matise on
If it's actually a TIME variable [a number] and not a char variable, you can
use hour() or whatnot [there's one for minute() and second() as well] to
extract it.
hourvar = hour(timevar);
No idea what else you mean by extract time, so perhaps you will want to post
back to the list with more specific desired results [ie, what you actually
want to get back in the same form as you posted your data] if this isn't
enough.

-Joe

On Tue, Jan 5, 2010 at 3:28 PM, db <daronnebonneau(a)gmail.com> wrote:

> Hi, I have a variable called Time with following format and would like
> to extract hour:time only so I can group by hour_time.
> Could you tell me how to extract hour and time from this Time
> variable ? Thanks
>
> Time
> 23:59:58.345
> 23:59:59.234
> 0:00:00.306
> 0:00:00.373
> 0:00:00.373
> .
> .
> .
> 01:00:00.765
>
From: Arthur Tabachneck on
Daronne,

Are you looking for something like:?

data have;
informat time time12.3;
format time time12.3;
input time;
cards;
23:59:58.345
23:59:59.234
0:00:00.306
0:00:00.373
0:00:00.373
..
..
..
01:00:00.765
;

data want;
set have;
hour_min=hms(hour(time),minute(time),0);
format hour_min hhmm5.;
run;

Art
--------
On Tue, 5 Jan 2010 13:29:20 -0800, db <daronnebonneau(a)GMAIL.COM> wrote:

>Hi, I have a variable called Time with following format and would like
>to extract hour:min only so I can group by hour_min.
>Could you tell me how to extract hour and min from this Time
>variable ? Thanks
>
>Time
>23:59:58.345
>23:59:59.234
>0:00:00.306
>0:00:00.373
>0:00:00.373
>.
>.
>.
>01:00:00.765