Date: Fri, 9 Oct 2009 10:22:55 +0200
Reply-To: Daniel Fernández <fdezdan@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Daniel Fernández <fdezdan@GMAIL.COM>
Subject: Re: ROLLING AVERAGES, DATA GROUPING
Content-Type: text/plain; charset=ISO-8859-1
at your dataset it seems mmdd variable as numeric (902 intead of 0902),
I can do it easier if it is char type as 0902.
can you confirm please?
2009/10/9 Joe DeVerna <firstname.lastname@example.org>:
> I am interested in grouping data by week in a sort of rolling average (e.g.
> average of all observations at week 1, obs. average at week 2 (but
> inclusive of week 1 observations, etc.).
> The basic shape of my data set follows:
> LOC YEAR MMDD VARIETY YIELD
> MA 2003 902 BL 57.67
> MA 2003 908 ST 145.16
> MA 2003 1008 EB 113.88
> MA 2003 1009 EB 58.11
> MA 2003 1030 H 121.49
> MMDD represents the month and day. I use this rather than the actual date
> as I want to compare cumulative weekly delivery trends over years for
> I define my weeks using the following approach:
> IF MMDD GE '0831' AND MMDD LE '0906' THEN WEEK1 = 'a 0831';
> IF MMDD GE '0907' AND MMDD LE '0913' THEN WEEK1 = 'b 0907';
> IF MMDD GE '0914' AND MMDD LE '0920' THEN WEEK1 = 'c 0914';
> IF MMDD GE '0921' AND MMDD LE '0927' THEN WEEK1 = 'd 0921'; etc.
> From there I need a simple tabular summary, e.g.
> PROC TABULATE DATA=New;
> CLASS LOC YEAR WEEK1;
> var Yield ;
> table WEEK1 , YEAR*Yield*(MEAN*f=5.1 ) / RTS=8;
> I am not an advanced SAS user so any explanation as to approach would be
> greatly appreciated.