Reeza - thank you for your patience - this is not how I usually code so I had to work through it a bit but I think this part is SOLVED. I would tag you but I do not see a way to do that. 🙂 Have a good evening.
@cbrotz wrote:
So I made a couple more changes below....zeroed out a field I am calling roll_tot at each break and then adding "sum_of_billings to that field to accumulate. I changed "mean" to "sum". I am not sure how that is going to affect the overall results but they look good from what I am seeing.
data ret_avg12;
set work.summary_ret_data;
by group_status fcst_prod_grp yyyymm;
array values(12) _temporary_;
if first.fcst_prod_grp then do;
call missing(of values(*));
count=0;
roll_tot=0;
end;
count+1;
roll_tot+sum_of_billings; *-> This line is wrong;
values(mod(count, 12)+1) = sum_of_billings;
if count>=12 then roll_tot=sum(of values(*));
format roll_tot dollar12.2;
run;
@cbrotz wrote:
Perhaps once I get a working example I will understand it better.
Both examples posted are fully worked examples with BY groups/breaks exactly like yours with also exactly a 12 month lag. The only difference is the source data set and variables and replace MEAN with the word SUM.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.