BookmarkSubscribeRSS Feed
Simi
Calcite | Level 5

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

2 REPLIES 2
data_null__
Jade | Level 19

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;

Simi
Calcite | Level 5

Thanks a lot, will definitelly remember INTNX now...

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 888 views
  • 0 likes
  • 2 in conversation