Suppose I have data in the following format:
Year Month Total
2009 4 16
2009 5 18
2009 6 12
2009 7 15
2009 8 11
2009 9 12
2009 10 7
2009 11 6
2009 12 9
2010 1 7
2010 2 8
2010 3 92
2010 4 3
2010 5 3
2010 6 3
2010 7 3
2010 8 5
2010 9 3
2010 10 08
2010 11 0
2010 12 2
2011 1 6
2011 2 5
2011 3 9
2011 4 17
2011 5 9
I am trying to obtain cumulative total of these observation (this alone would not be difficult), however I want the cumulative counter to 'reset' at the beginning of financial year (i.e. get cumulatives for 04/2009 - 03/2010, 04/2010 - 03/2011 etc.). Could anyone suggest appropriate code?
Thank you,
Simi
INTNX with shift.
data test;
input Year Month Total;
date = mdy(month,1,year);
fyear = intnx('year.4',date,0);
format date fyear date9.;
cards;
2009 4 16
2009 5 18
2009 6 12
2009 7 15
2009 8 11
2009 9 12
2009 10 7
2009 11 6
2009 12 9
2010 1 7
2010 2 8
2010 3 92
2010 4 3
2010 5 3
2010 6 3
2010 7 3
2010 8 5
2010 9 3
2010 10 08
2010 11 0
2010 12 2
2011 1 6
2011 2 5
2011 3 9
2011 4 17
2011 5 9
;;;;
run;
proc print;
run;
proc freq;
weight total;
tables fyear;
format fyear year.;
run;
Thanks a lot, will definitelly remember INTNX now...
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.