04-27-2015 10:22 AM
Hi, I've got a date field in my table and I need to get the most recent date in it.
I'm working in SAS VA 7.1 and tried creating an item field using the MAX function but gives me error.
any idea how can I get the max date ?
04-27-2015 10:53 AM
Show use what you did and the error.
Also, make sure your dates are SAS date values and not a character variable that looks like a date.
04-27-2015 05:39 PM
If you just want to display the most recent date in a table, the simplest solution is to sort a table in descending order by your date column.
I don't think there is an easy way in the VA expression syntax to calculate the most recent date.
You can use the TreatAs operator in a calculated measure to convert the date into a numeric, and then create an aggregated measure using the Max() operator on that calculated item. This will give you the most recent date, but the date is no longer in date form. It will look like this: 19833.
04-28-2015 01:14 AM
If you want to show Max date in VA, you have to create Max date column in SAS table using MAX function.
As per sam you can Calculate Max date using calculated items(Treat As) and Aggregated Measures(_Max_). but the result will be in sas days.
04-27-2017 01:47 PM
so what is the final solution of showing the MAX(Date)
i can do the treat as and max and get a result.
how do i get that back to a date?
04-28-2017 08:18 AM
If you want top see the date in a table
In the example above I have a second column showing when the data was refereshed by sas, to do this I just added column in my underlying data query which inserts todays date against every row.