Show us your current code
Just an idea: appending 01 ... 40 to the file name, so that after the 40th file is written, 1st file be overwritten on the next day. The tricky part is maintaining the counter in sas over session. You need to store it in a file (on the sas side) and process it each time a file is written.
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.