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

Getting max date value in SAS VA

Reply
Frequent Contributor
Posts: 84

Getting max date value in SAS VA

Dear Experts,

 

I have two variables ID and Date. I need to get a max date value, tried everything but not able to find a way so please help me.

ID dates
B0001 01/17/2018
B0002 11/20/2017
B0003 01/16/2018
B0004 11/19/2017
B0005 01/15/2018
B0006 11/18/2017
B0007 01/14/2018
B0008 11/17/2017
B0009 01/13/2018
B0010 11/16/2017
PROC Star
Posts: 392

Re: Getting max date value in SAS VA

[ Edited ]
Posted in reply to Rahul_SAS

What do you want to do more specific?
The easiest way is to add a list table and then sort in descending date order and look at the first row Smiley Wink

//Fredrik

Frequent Contributor
Posts: 84

Re: Getting max date value in SAS VA

Hi Fredrike,

 

My requirement is to calculate and create a data item which should contain the latest data i.e. 17 Jan 2018 in the given sample data.

That data item will be used in a button bar to highlight Data Refreshed On.

 

I hope, I am making sense here.

 

Thanks

SAS Super FREQ
Posts: 322

Re: Getting max date value in SAS VA

[ Edited ]
Posted in reply to Rahul_SAS

Hello Rahul,

 

Here is a previous discussion about max date in VA:

https://communities.sas.com/t5/SAS-Visual-Analytics/About-getting-the-max-date-in-a-table-field/m-p/...

 

If you just want to display the max date in your report, you can use a rank to select the "top 1" date.

 

If you need to perform any calculations using the max date, you will need to create a column in your data query using the MAX() function.

 

Also in 8.2 or 7.4, you can display the timestamp of the most recent update to the data source in a Text object. (Search the doc for "Dynamic Text") But this is not necessarily the same thing as the max date in your data and I believe you cannot do any calculations with this value.

 

Let us know if this helps.

 

Thanks,

Sam

PROC Star
Posts: 392

Re: Getting max date value in SAS VA

Posted in reply to Rahul_SAS

Oki!

Create a new calculated item, use your date variabel and "treatAs" number. Set aggregation to max.

Add a button bar and set your date variabel as category, then rank and pick the highest 1 from your calculated variable.

This will make your button bar show only the highest date in your data.

//Fredrik

Frequent Contributor
Posts: 84

Re: Getting max date value in SAS VA

hi Fredrik,

 

please guide me how to set a date variable to category variable.

 

thnx

SAS Super FREQ
Posts: 322

Re: Getting max date value in SAS VA

[ Edited ]
Posted in reply to Rahul_SAS

Hi Rahul,

You can assign your date variable to the Category role of the button bar. It is not necessary to convert it to a category data type.

Sam

PROC Star
Posts: 392

Re: Getting max date value in SAS VA

Posted in reply to Rahul_SAS

As @Sam_SAS says assign it as category role of the button bar, I translated my swedish to english, my bad Smiley Happy

//Fredrik

Ask a Question
Discussion stats
  • 7 replies
  • 413 views
  • 3 likes
  • 3 in conversation