I would strongly suggest looking for an alternative to SQL. Your table is a bit confusing because the rows show "Y+1" which makes it appear as if they would span multiple years, but your columns indicate the years and your row label makes it appear your sums should be cumulative rather than just a sum within each month*year combination. If you truly want cumulative sums without necessarily having data for each of the month*year combinations, then you may need to augment your data set to include every month*year combination before computing the sums, otherwise SAS will not include rows/columns where no data appears in the data set. If this were my client, I would want a more clear understanding of exactly how those values are supposed to appear in the table. Then I would go to the DATA step and build out what I needed to get my sums (for example, I included a DATA step below), then I would go to PROC REPORT and print them. It isn't a single-step solution, but your data does not appear to be in a format that would allow us to provide a single step that gets exactly the output you want. data want(drop = id sales);
set have;
by year month date;
if first.year then total = 0;
total+sales;
if last.month then output;
run;
... View more