## Which day of the week has highest number of accidents?

Solved
Regular Contributor
Posts: 238

# 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
Posts: 3,167

## 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

All Replies
Super User
Posts: 23,683

## 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: 238

## 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
Posts: 3,167

## 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: 23,683

## 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 and locked.