I'm trying to calculate 6-quarter and 10-quarter percent change of sales values for my time-series data. These values need to be calculated for sales within each customer and each region. For example, for 6-qtr percent change for the observation from 2004Q2, I would calculate the percent change as pctchange = [(sales in 2004Q2) - (sales in 2003Q1)] / (sales in 2003Q1). This value would then be multiplied by 100 to be shown as a percent. The values before this date would be empty since there are not 6 full quarters of sales to calculate from. So, another example, 6-qtr percent change for the value at 2005Q3 would be pctchange = [(sales in 2005Q4) - (sales in 2004Q3)] / (sales in 2004Q3) then multiplied by 100. The 10-qtr percent change values would be calculated the same way, only with a width of 10 quarters instead of 6. I was trying to mess with coding some loops, but I can't seem to figure out a way to do this. I'm using SAS Enterprise Guide. Here is a sample subset of my data: data sample; input customer region qtr year sales; informat qtr yyq6.; format qtr yyq6.; datalines; 1 2 2003Q1 2003 0 1 2 2003Q2 2003 0 1 2 2003Q3 2003 3 1 2 2003Q4 2003 5 1 2 2004Q1 2004 3 1 2 2004Q2 2004 0 1 2 2004Q3 2004 6 1 2 2004Q4 2004 2 1 2 2005Q1 2005 0 1 2 2005Q2 2005 4 1 2 2005Q3 2005 0 1 2 2005Q4 2005 2 2 6 2003Q1 2003 0 2 6 2003Q2 2003 0 2 6 2003Q3 2003 3 2 6 2003Q4 2003 5 2 6 2004Q1 2004 3 2 6 2004Q2 2004 0 2 6 2004Q3 2004 6 2 6 2004Q4 2004 2 2 6 2005Q1 2005 0 2 6 2005Q2 2005 4 2 6 2005Q3 2005 0 2 6 2005Q4 2005 2 ; run;
... View more