Subscribe Bookmark RSS Feed

average by month

paulp

Community Trekker

Joined:

Jun 30, 2011

I have ratings data for different locations across 2009-2011.  The data formatted in two columns => rating | date   e.g. 0.85 | 06/29/2010.  How can I average the ratings by month?  thanks, Paul

2 REPLIES

Hi Paul,

There are many ways you could do this. You could create a variable that is by month and year and use SQL to do the aggregation or you could do this in a data step with by group processing (assuming you had your month & year variables) or you could simply use proc means.

Syntax will be something like...

proc means data=mydata mean; *if you want the default statistics then remove mean here otherwise it will give you the average ratings by month;

     var rating;

     class date;

     format date monyy7.; *This is to get the 12 month categories for each year;

run;

Doing the above avoids having to spend time creating new variables etc and you take advantage of the benefits of using a SAS format for group processing.

I hope this helps.

Cheers,

Michelle

MTOF

Community Trekker

Joined:

Jun 29, 2011

Hi Paul

Assuming your columns are called Rating and Date


You could add two columns Month and Year with the formulas month(Date) and year(Date) (they are both in the Date Time group) respectively.

Then do Tables/Summary, Statistics:Mean of Rating and Group:Year and Month.

BR, Marianne