Hi everyone!
I'm kinda new to the SAS VA and I'm not being able to create a specific calculated field.
The idea is to calculate the average revenue/coupons we'll have to make on the rest of the year to complete our year goal.
My data is on the store level, so I'll have to aggregate it to make these as big numbers. I've attached a sample of the table I'm using.
The difficult part is to calculate the amount of months left in the year to use it as the denominator. Using the revenue as example, the formula I thought was something like:
Sum [_ForAll_] ((
IF ( Month('anoMesData'n) <= ( Month(DatePart(Now())) - 1 ) )
RETURN 'revenueGoal2020'
ELSE . )) -
Sum [_ForAll_] ((
IF ( Month('anoMesData'n) <= ( Month(DatePart(Now())) - 1 ) )
RETURN 'revenue2020'
ELSE . ))/
202012 - Month(DatePart(Now()))
Is this the best way to make this calculation?
Thanks!
Hello!
So, a person from my area was able to help me on this problem. I only needed to put a function to aggregate the data of the denominator.
The formula that worked stayed like this:
( Sum [_ForAll_] ('revenueGoal2020'n) - Sum [_ForAll_] ((
IF ( Month('MONTH_YEAR'n) <= ( Month(DatePart(Now())) - 1 ) )
RETURN 'revenue2020'n
ELSE . )) ) / Max [_ForAll_] (( 12 - ( Month(DatePart(Now())) -
1 ) ))
Just updating:
I was able to put the logic on a formula, but it's giving an error because the denominator is not aggregated.
The formula I've programmed is:
( Sum [_ForAll_] ('revenueGoal2020'n) / Sum [_ForAll_] ((
IF ( Month('DATE'n) <= ( Month(DatePart(Now())) - 1 ) )
RETURN 'revenue2020'n
ELSE . )) ) / ( 12 - ( Month(DatePart(Now())) - 1 ) )
Am I doing something wrong?
Thanks!
Hello!
So, a person from my area was able to help me on this problem. I only needed to put a function to aggregate the data of the denominator.
The formula that worked stayed like this:
( Sum [_ForAll_] ('revenueGoal2020'n) - Sum [_ForAll_] ((
IF ( Month('MONTH_YEAR'n) <= ( Month(DatePart(Now())) - 1 ) )
RETURN 'revenue2020'n
ELSE . )) ) / Max [_ForAll_] (( 12 - ( Month(DatePart(Now())) -
1 ) ))
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.