BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Kroken
Calcite | Level 5

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Sam_SAS
SAS Employee

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:

http://support.sas.com/documentation/cdl/en/vaug/68648/HTML/default/viewer.htm#n1lxnqfip132can1hdzue...

 

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

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Sam_SAS
SAS Employee

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:

http://support.sas.com/documentation/cdl/en/vaug/68648/HTML/default/viewer.htm#n1lxnqfip132can1hdzue...

 

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

Kroken
Calcite | Level 5

Thanks - both of you!

sas-innovate-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

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.

Discussion stats
  • 3 replies
  • 1661 views
  • 0 likes
  • 3 in conversation