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

How to change the date expression to numeric after creating 'New Calculated Item' in SAS VA

Reply
Occasional Contributor
Posts: 16

How to change the date expression to numeric after creating 'New Calculated Item' in SAS VA

Hi, I am trying to do new calculated item in the Report Designer to calculate 'now() - timestamp' to give a total number of days. Can someone please advise how do I do the calculation. And how to show the result in numeric?

 

Thank you.

SAS Employee
Posts: 31

Re: How to change the date expression to numeric after creating 'New Calculated Item' in SAS VA

It is a little cumbersome, but you can use the DayOfYear and Year functions to return numeric values from the two dates ('now' and 'timestamp').  Also you have to wrap 'Now()' in a DatePart() function:

 

 

365*( Year(DatePart( Now() )) - Year( timestamp ) + DayOfYear( DatePart( Now() )) - DayOfYear( timestamp )

SAS Employee
Posts: 31

Re: How to change the date expression to numeric after creating 'New Calculated Item' in SAS VA

Posted in reply to MikeJenista

I checked if a simpler calculation would work:

 

DatePart( Now() ) - timestamp

 

But it did not.  I think this is because the underlying SAS date value is not a supported format for VA content, but I can check on it with some folks I know in development.

Ask a Question
Discussion stats
  • 2 replies
  • 77 views
  • 0 likes
  • 2 in conversation