BookmarkSubscribeRSS Feed
sascode
Quartz | Level 8

Hello,
Let say i am recording every work day the incoming orders at each hour from 6 a.m to 4 p.m. My goal is to calculate the hourly average.
I can create a summary table for the entire data with to columns , first called hour , where will be time in hour from 6 a.m to

4  p.m(there are 11 different time points) and second column with count order for each hour.
My goal is to calculate the hourly average.
I would appreciate any idea suggested.
Thanks.

7 REPLIES 7
ballardw
Super User

By hourly average do you mean the "6AM" across multiple days?

 

If you haven't entered data I would suggest entering the data as something that looks like:

 

Date             Time   Count

2020-11-25   06:00   15

2020-11-25   07:00   15

2020-11-25   08:00   15

2020-11-25   09:00   15

2020-11-25   10:00   15

2020-11-25   11:00   15

2020-11-25   12:00   15

2020-11-25   13:00   15

2020-11-25   14:00   15

2020-11-25   15:00   15

2020-11-25   16:00   15

 

This will eventually allow you have datetime values and there a lots of functions and tools that allow you to manipulate them.

If I wanted to summarize across days for the same time of day you would use something like

 

Proc means data=have  mean min max;
    class time;
    var count;
run;

which would give you the mean, minimum and maximum value of Count for each time period.

Or one of the report procedures.

The Time this way would also allow you to create intervals for reporting. With the DATE you can tell weekdays from weekends or holidays and such as well.

sascode
Quartz | Level 8
First thanks for replying,
My question is more related to the best way of calculating this average in terms of mathematical representation than coding part.
Again ,in my opinion , if i divide each hourly count with the number of days than my measure can not be more hourly avg because it will also depend on day numbers either.(Just my opinion)
I am more in direction of dividing each hourly count by the number of total hours.(Not sure if i am right in this way of doing it)
Thank you.
Reeza
Super User

I think it would be helpful to present some data here to explain your methodological issues. Not sure why you wouldn't just conceptually do an average and if you're looking for methodological advice you'll also need to provide more context, what you're trying to represent and show is important. In certain cases it doesn't make sense to look at averages at all, sometimes you need standard deviation instead or median or max or 95th percentile. 

 


@sascode wrote:
First thanks for replying,
My question is more related to the best way of calculating this average in terms of mathematical representation than coding part.
Again ,in my opinion , if i divide each hourly count with the number of days than my measure can not be more hourly avg because it will also depend on day numbers either.(Just my opinion)
I am more in direction of dividing each hourly count by the number of total hours.(Not sure if i am right in this way of doing it)
Thank you.


 

sascode
Quartz | Level 8
Hello again,
It is fine,
i do not like you to spend to much on time on it (I really appreciate ),
Below is how data looks for first two work days for example.
Hour Orders
6 11
7 15
8 8
9 7
…. …
16:00 5
ballardw
Super User

@sascode wrote:
Hello again,
It is fine,
i do not like you to spend to much on time on it (I really appreciate ),
Below is how data looks for first two work days for example.
Hour Orders
6 11
7 15
8 8
9 7
…. …
16:00 5

So describe exactly how you get 5? Please show the actual arithmetic. And if you used values you did not show, then show them.

sascode
Quartz | Level 8
I count for all days how many times the 16:00( 4 p.m) is appeared .I saw it 5 times,
6 a.m is appeared 11 times and so on,
Thank you.
ballardw
Super User

@sascode wrote:
I count for all days how many times the 16:00( 4 p.m) is appeared .I saw it 5 times,
6 a.m is appeared 11 times and so on,
Thank you.

That is a simple count based on the hour LOTS of ways to get counts: Proc Freq, Proc Report, Proc Tabulate, Proc Summary are just a few.

 

Proc freq data=have;

   tables time ;

run;

 

Proc report data =have;

   columns time n;

   define time /group;

run;

 

Proc tabulate data=have;

    class time;

    table time , n;

run;

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 892 views
  • 0 likes
  • 3 in conversation