Which day of the week has highest number of accidents?

Accepted Solution Solved
Reply
Regular Contributor
Posts: 212
Accepted Solution

Which day of the week has highest number of accidents?

Would someone please suggest the SAS procedure for arriving at the answer?

Two columns of data.

Day of Week would be the numbers 1 - 7, a categorical variable.

Response variable Accidents would be daily numbers, a continuous variable.

Number of rows in data set is greater than 1000.

Any guidance appreciated.

Nicholas Kormanik


Accepted Solutions
Solution
‎06-06-2012 10:51 PM
Respected Advisor
Posts: 3,124

Re: Which day of the week has highest number of accidents?

Or Proc SQL approach:

data have;

input week$ accident;

cards;

1 23

2 324

3 134

1 134

2 367

3 87

1 56

;

proc sql;

select * from

  (select week, mean(accident) as max

  from have

  group by week)

   having max=max(max);

  quit;

Haikuo

View solution in original post


All Replies
Super User
Posts: 17,737

Re: Which day of the week has highest number of accidents?

Two possible options

1. Proc FREQ -

proc freq data=have;

     table day_of_week/chisq;

weight count;

run;

But that won't tell you which one is higher.

2. An ANOVA based on the average number per day of week with contrast tests to isolate the one that is the highest.

Regular Contributor
Posts: 212

Re: Which day of the week has highest number of accidents?

What would be the code for ANOVA?

Sounds right, that SAS would have to calculate the average number of accidents for each day (1-7), and assess whether there is a significant difference between the days.

Frequent Contributor
Posts: 87

Re: Which day of the week has highest number of accidents?

*get mean accidents per day;

proc summary noprint nway n

    data = have ;

            class days ;

            var accidents ;

    output out = want (

                    drop = _type_ _freq_)

        mean(accidents) = mean_accidents ;

run ;

Then run a proc rank to get the highest if required.

Solution
‎06-06-2012 10:51 PM
Respected Advisor
Posts: 3,124

Re: Which day of the week has highest number of accidents?

Or Proc SQL approach:

data have;

input week$ accident;

cards;

1 23

2 324

3 134

1 134

2 367

3 87

1 56

;

proc sql;

select * from

  (select week, mean(accident) as max

  from have

  group by week)

   having max=max(max);

  quit;

Haikuo

Super User
Posts: 17,737

Re: Which day of the week has highest number of accidents?

I've been thinking as a statistician too long...did you need to test if its significantly different as well, or just after the largest number?

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 286 views
  • 3 likes
  • 4 in conversation