HI -
I'm new to SAS VA and this community and would like to see if anyone here can help me to solve a problem I have when designing a report. I want to create a graph showing percent difference from a fixed previous period (the first date in my data). I do not really understand how I can achieve this from the optional settings in the aggregated measure editor. Does anyone have any kind of solution for this?
Kind regards,
Mats
P.S It doesnt have to be solved within the editor - any solution woud be greatly appreciated.
If the reference date can be hardcoded, then you could use the PeriodWithDate operator.
For example, you might use an expression like this to compare the values of Sales for each month to the value from JAN2015:
Period(_Sum_, 'Sales'n, 'Date'n, _ByMonth_) - PeriodWithDate(_Sum_, 'Sales'n, 'Date'n, _ByMonth_, '01JAN2015'd)
Documentation for Period() and PeriodWithDate() can be found here:
Hope that helps.
If the first date in the data set needs to be determined dynamically, I don't think that can be done easily in the expression editor. You will need to use SAS code in your data query to evaluate it.
Sam
Well, I don't use VA so my answer here is going to be general SAS code. What I would do, and its per the models in my field, is to extract the baseline value, then merge that back to the original data. So (and you have not posted and test data in the form of a datastep so this is just example):
Some examplpe data:
Id Period Result
1 1 123
1 2 345
1 3 456
data base (rename=(result=base)); set have;
where period=1;
run;
data want;
merge have base;
by id;
run;
Now in this case, all records in the original dataset have a column base from the fixed period, and you can calculate across.
If the reference date can be hardcoded, then you could use the PeriodWithDate operator.
For example, you might use an expression like this to compare the values of Sales for each month to the value from JAN2015:
Period(_Sum_, 'Sales'n, 'Date'n, _ByMonth_) - PeriodWithDate(_Sum_, 'Sales'n, 'Date'n, _ByMonth_, '01JAN2015'd)
Documentation for Period() and PeriodWithDate() can be found here:
Hope that helps.
If the first date in the data set needs to be determined dynamically, I don't think that can be done easily in the expression editor. You will need to use SAS code in your data query to evaluate it.
Sam
Thanks - both of you!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.