How to run a different query if the output table is empty.
My current query is:
PROC SQL;
CREATE TABLE WORK.QUERY_FOR_A_KUNDESCORINGRATINGRE AS
SELECT t1.PD,
t1.DATO,
t1.KSRUID
FROM DLKAR.A_KUNDESCORINGRATINGRETRO t1
WHERE t1.KSRUID = 6 AND t1.DATO = '31Aug2022'd;
QUIT;
But I would like to make a conditional statement to run the query again if it is empty but with the filter t1.DATO set to '31Jul2022'd instead of august. So every time the query fails on a given date the query tries again one month earlier.
I hope you can point me in a direction.