Using a DATA step, you would need to use the INPUT function to test the data -- SAS will return a MISSING value if invalid, then set a DO/END loop decrementing by one and again testing the value using INPUT.
For consideration, the INPUT example below shows how to tell SAS to suppress an invalid-data condition from the SASLOG:
If, as your sample suggests, you are only worried about the last day of the month, the following uses Scott's suggestion to create a new date value.
date = INPUT(a,?? DATE9.);
if date= . then do;
format date date9.;
proc print data=last;
Clearly there are other date traps that may concern you.