Exploring, modeling, predicting and reporting with SAS Visual Analytics and SAS Visual Statistics

Calculate a cumulative sum over a period longer than 1 year?

Reply
New Contributor
Posts: 3

Calculate a cumulative sum over a period longer than 1 year?

Hello,

I want to create variables that calculate a cumulative sum (running sum) over a period longer than 1 year. Perhaps I'm doing something wrong, but using CumulativePeriod or the other options the Cumulative sum begins again from 0 as the year changes

Can anyone help me solve this.

Thanks in advance

Chris Keen

SAS Employee
Posts: 232

Re: Calculate a cumulative sum over a period longer than 1 year?

ChrisKeen,

My apologies--I accidentally marked your question "answered" by mistake. I'm currently having trouble undoing my mistake.

I believe it is possible for you to mark the question back to "unanswered."  My posting this message will bump your question back up in the activity stream - hopefully someone will see and get you some help.

I'm sorry for the inconvenience. Thank you for being part of the community!

Communities Admin

Regular Contributor
Posts: 196

Re: Calculate a cumulative sum over a period longer than 1 year?

Hi Chris,

I think you are trying to calculate cumulative sum for financial year, if yes, it is not possible to calculate in this way, you can do this using custom category, cumulative period is only for calendar year  (i.e.., Jan - Dec).

Lets hope that this option (YTD) is available in VA 7.2.

You want to compare  MOM?

Regards,

Teja Surapaneni.

New Contributor
Posts: 3

Re: Calculate a cumulative sum over a period longer than 1 year?

Hello Teja,

Thanks for your reply. I am trying to calculate for a periode, for example from 1-1-2014 to date (in february 2015  the periode to calculate is 1-1-2-14 to 1-2-2015, or in June 2015, the period should be  1-1-2014 - 1-6-2015).

Have you an example that shows me how I can manually calculate this.

Thanks again

Regrads

Chris keen

Regular Contributor
Posts: 196

Re: Calculate a cumulative sum over a period longer than 1 year?

hi,

You Want Cumulative Sum or Overall Sum ?

Thanks,

Teja Surapaneni.

New Contributor
Posts: 3

Re: Calculate a cumulative sum over a period longer than 1 year?

Hi

I want a cumulative (running) sum - using my example in my the discussion meassge,  from march 2014 til march 2015 without breaking and starting again from jan. 2015

Thansk again

New Contributor
Posts: 2

Re: Calculate a cumulative sum over a period longer than 1 year?

I'm having the same problem. Stuff does accumulate from year to year sometimes, has anyone figured out how to convey this in VA?

SAS Super FREQ
Posts: 275

Re: Calculate a cumulative sum over a period longer than 1 year?

Hello jay and Chris,

There have been a few threads on this topic.

I asked a developer who supports the periodic operators about this, and he doesn't know of a workaround in the current release. This feature is definitely on our radar, so hopefully it can be implemented in a future release.

Thanks,
Sam

New Contributor
Posts: 2

Re: Calculate a cumulative sum over a period longer than 1 year?

Thanks Sam for letting us know

New Contributor
Posts: 2

Re: Calculate a cumulative sum over a period longer than 1 year?

Hi,Sas2Year.jpg

I have made a calculation for running sum over a period longer than 1 year like this:

1. Data Set: DATE (in MM/YYYY format); Value

2. + Date2Year=DateFromMDY(1, ( Month('DATE'n) + ( ( Year('DATE'n) - 2014 ) * 12 ) ), 2015)

3. + Value2Year=CumulativePeriod(_Sum_, 'Value'n, 'Date2Year'n, _Inferred_, _Inferred_, 0, _Full_, {Date})

4. + No.='Date2Year'n. Format display as Day of Month. "No." is needed to replace "Date2Year" in the Table.

Same technic I'm using for calculating: day to day difference, week to week difference, cumulative sum by days in week, etc.

I hope it's clear and will help.

Robert R.

Learner
Posts: 1

Re: Calculate a cumulative sum over a period longer than 1 year?

[ Edited ]

Hi,

 

I think you are limited to 365 values with this solution.

I have to do a cumulative with data on more than 1 year and one data per day.

I created date2year in SAS Base like this : date2year = '01jan2015:0:0:0'dt + datepart(date);

In Visual Analitics, i created value2year like : CumulativePeriod(_Sum_, 'Value', 'Date', _Inferred_, _Inferred_, 0, _Full_, {Date})

 

But value2year stays empty, I think this is due to the fact that date2year is in datetime format...

Have you any solution ?

 

Thanks

Occasional Contributor
Posts: 6

Re: Calculate a cumulative sum over a period longer than 1 year?

Hi,

There is solution - but very, very slow for daily summing, better for month, good for quarter or year summing

 

For e.g. data for 2014, 2015 years

"Quantity" - aggregated measure

"Date" - calendar data

 

1. YearNo = Year('Date'n)  measure

2. QtyYTD = CumulativePeriod(_Sum_, 'Qty'n, 'Date'n, _Inferred_, _ByYear_, 0, _Full_, {Date})  aggregated

3. QtyPrevYear = IF ( Avg [_ByGroup_] ('YearNo'n) = 2014 ) RETURN 0 ELSE ParallelPeriod(_Sum_, 'Qty'n, 'Date'n, _ByYear_, _ByYear_, -1, _Full_, {Date})  aggregated

4. Qty2YTD='QtyPrevYear'n + 'QtyYTD'n  aggregated - gives sum we are looking for

2YearSum_1.jpg

 

2YearSum_2.jpg

 

2YearSum_2.jpg

 

Best Regards

Robert R.

 

 

Post a Question
Discussion Stats
  • 11 replies
  • 3187 views
  • 4 likes
  • 8 in conversation