Strong suggestion: Do not place date information in character variables if you ever want to apply an order to the resulting values.
Use an actual SAS date value (numeric number of days since 1 Jan 1960) and a format to display the information.
Except for the "th" (and implied "st" "nd" or "rd" which I personally find unprofessional in appearance with dates) you can get very similar date text using a custom picture format. I am assuming the day of the week text is critical so create a longer version of the SAS Worddatew. format
Proc format library=work;
picture longworddate (default=25)
low-high ='%3b %d, %Y (%F)' (datatype=date);
run;
data example;
x=today();
format x longworddate.;
run;
The picture format directives, the bits that start with % above are: %3b 3-character month abbreviation with mixed case, %d is the numeric day of the month, %Y 4-digit year, %F day of week text. The other characters of space, comma and parentheses are used as they appear.
Example (after getting a working data set) the across order for the given values of Var7 (really need better names) is:
Apr 10th, 2024 (Wednesday)
Apr 8th, 2024 (Monday)
Apr 9th, 2024 (Tuesday)
This is because 1 in a character value comes before 8. Using a two-digit day with leading 0 would allow the dates to sort in day of month order but will typically not appear as desired if your dates cross a month boundary. Consider March 30 to Apr 3 for a report. The data would sort Apr 1, Apr 2, Apr 3, Mar 30, Mar 31 .
If the values are actual dates they would appear in increasing order by default or you could provide instructions to have then in descending order. But with character values you are going to have problems with order.
... View more