OK, here's an attempt. Like I said, I expect someone who knows SQL much better will fix this and make it look more professional. I'm going to assume you have already replaced DATE1 with the equivalent SAS date, something along the lines of: date1 = input( put(date1, 8.), yymmdd8.); This could then be a piece of the solution, creating _2wkprecip for the X1 records. Please adjust the date ranges using an equal sign (<= or >=), as appropriate. (You may also need to do a little debugging ... I tested pieces of the logic but not the whole thing.) proc sql; create table x1 as select distinct x1, date from original where x1='X1'; create table to_be_summed as select a.x1, a.date, b.precip from x1 as a, original as b where (b.date1 < a.date) and (b.date1 + 14 > a.date); create table x1_2weeks as select x1, date, sum(precip) as _2wkprecip from to_be_summed group by date; quit; Until someone "fixes" the code, you would need a similar group of statements for each time period, and for X2, X3, etc. There remains the final task of putting the pieces together. But this gives you a starting point. Good luck.
... View more