BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
NKormanik
Barite | Level 11

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

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

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

5 REPLIES 5
Reeza
Super User

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.

NKormanik
Barite | Level 11

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.

SteveNZ
Obsidian | Level 7

*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.

Haikuo
Onyx | Level 15

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

Reeza
Super User

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?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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