This was most helpful and it looks like I need to start learning the SQL Procedure. I can see that you put three 'tables' together and it appears that proc sql understands the temporal values (WEEK6, etc...). I will read up but there are a few things I would like to follow up on. In the data step: input d date9. x1 $ 10-15 x2 $ 16-21 precip 22-30; - I by pased this portion of the code since my date was already formated as a SAS date. But my question is why did you specify the spacings for each variable, is that style or does proc sql want strict spacing at times? In proc sql: where d between intnx(interval, refDate-1, -1, "SAME") and refDate - This ended up including an extra day in the summation and included the refDate itself in the summation (which was not something I discussed). I modified the code to: where d between intnx(interval, refDate, -1, "SAME") and refDate-1 This gave me the exact number of days up to but not including the sample date(WEEK2 = 14 days before the reDate not including the reDate). With the sample date aside, was there a reason for using refDate-1 in the expression? as it appears that this increases the time interval by 1. Also, adding the ':' at the end of a variable or unwanted character was not a trick I learned. Is there a reference somewhere where I can find more of the basic programming syntax? I am pretty much self taught and things like this make it a lot easier for me. Thanks again, I have learned a lot from your answer.
... View more