Can DM.RFPENDTC have a partial dates? If yes, how do we take max of a partial dates?
If this is a SAS table and the variable is numerical with a SAS Date or DateTime format attached (=how SAS stores dates) then no, because such dates are counts of days since 1/1/1960 or datetime values are counts of seconds since 1/1/1960 and such counts can't be "partial".
If the variable is of type character then yes, the string could be partial and you would need to convert it to a SAS date or datetime value before you can derive the max - and if and how SAS can convert partial date strings to a SAS date value is documented (look at informats for dates and datetimes).
Are you talking about CDISC datasets?
I think the C in the DTC suffix stands for CHARACTER.
To find the maximum or character strings in YYYY-MM-DD order you can just take the MAX() since strings in that pattern when sorted lexigraphically will also be sorted chronologically. Note that will treat partial dates as being before any actual date in that month (or year) since spaces are less than digits.
If you want to use some other algorithm then you will need to convert the partial dates into actual dates. For example it is common to pick the middle of the interval. So the 15th if the day of the month is missing. June if the month is missing. This could yield a different maximum than sorting the partial date strings lexigraphically.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.