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

Define dynamic Measure/Category Names

Occasional Contributor
Posts: 15

Define dynamic Measure/Category Names

I have a report that will be published year to year and I'd like to cut down on the maintenance needed.  I have a lot of aggregated measures for example.  


Here's some sample code:

Sum [_ByGroup_] ('Ordered 2017'n) - Sum [_ByGroup_] ('Ordered 2016'n)


I have a chart which has the year as a category.  So next year the columns will be 'Ordered 2018' and 'Ordered 2017'.  Is it possible for me to do something that will dynamically adjust these column names in the code so that they're not hardcoded and will always be the current year and current year-1.



Super User
Posts: 5,917

Re: Define dynamic Measure/Category Names

Having measures variables created according to time is awkward, it's more like an Excel layout.
That said, it isn't obvious how to deal with calculations like yours in VA, makes one miss OLAP cubes sometimes....
I don't have access to VA at this point, but a vague idea.
First restructure your data so you have a time classification variable instead (like year, if that is your preferred granularity).
Then you perhaps could use the ParallelPeriod periodic operator to retrieve last years values.
Data never sleeps
Super User
Posts: 4,023

Re: Define dynamic Measure/Category Names

SAS VA formulas can only be changed manually so you would be stuck with editing your code each year. Best practice in VA would be to use relative definitions like current year and last year.

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation