Break down time into 1/4 hour groups

Reply
Occasional Contributor
Posts: 6

Break down time into 1/4 hour groups

I need to break down time into 1/4 hour groups to see when most people showed up at an event. Is there anyways to do this?

I am not sure how to include time into the code.

Super User
Posts: 11,343

Re: Break down time into 1/4 hour groups

What does your starting data look like? What should the output look like? Provide some example of what you have and what the output should look like.

Occasional Contributor
Posts: 6

Re: Break down time into 1/4 hour groups

The time variable right now is:

time

00:25:00

09:01:00

12:04:45

23:06:52

I need it to break it down into quarter hours: so something like the following

time             group

00:25:00         2

09:01:00         37

12:04:45         49

23:06:52         93

There are a lot more observation than this. But i am thinking just dividing them into groups would be appropriate.

Super User
Posts: 11,343

Re: Break down time into 1/4 hour groups

data junk;
informat time time.;
input time;
format time time.;

group= round(time/900,1);
datalines;
00:25:00
09:01:00
12:04:45
23:06:52
;
run;

Occasional Contributor
Posts: 6

Re: Break down time into 1/4 hour groups

would it change anything if the dataset is already a dataset….this is like over a million time observations so I am not sure how to get around using a datelines; step.

Valued Guide
Posts: 860

Re: Break down time into 1/4 hour groups

No, I like Xia's response, datalines is only to show the example,

data want;

set have;

group= ceil(time/'00:15:00't);

run;

Valued Guide
Posts: 860

Re: Break down time into 1/4 hour groups

data have;

input time;

informat time time8.;

format time time8.;

cards;

00:25:00

09:01:00

12:04:45

23:06:52

;

run;

data want;

set have;

group = round(time / (60*15));

run;

Super User
Posts: 10,023

Re: Break down time into 1/4 hour groups

Code: Program

data junk;
informat time time.;
input time;
format time time.;
group= ceil(time/'00:15:00't);
datalines;
00:25:00
09:01:00
12:04:45
23:06:52
;
run;
Ask a Question
Discussion stats
  • 7 replies
  • 329 views
  • 1 like
  • 4 in conversation