This doesn't make a whole lot of sense. Why multiply the date by -1, that will cause issues down the road. You have multiple checks for day of week 1?
1. Look at DOWNAME format.
%let dow=%sysfunc(today(), downame.);
%put &dow.;
2. Where is the error being generated from? You've posted a lot of code - what's the actual issue?
3. I don't see the keyword BETWEEN so not sure what you're referring to here.
If you're trying to increment the date use the INTNX function rather than -1 to make sure it evaluates properly.
You have a Teradata error but do no show any connection, so missing some information.
Also putting quotes into macro variables frequently causes issues and your DT varaible has spaces inside the single quotes which may be even more problematic depending on use.
I would also suggest use of DATE9. so that you have a 4 digit year just in case year values become an issue. Some other program may assume that 16 is 1916.
If you don't expect years like 19xx in your data then add to your code:
options yearcutoff = 2000;
You don't show the actual Teradata call, so a bit guessing here.
If you are using implicit pass through (using Libname to Teradata), I assume that you need to use a SAS date literal, you can either extend your macro variable, or add it at macro variable resolution.
If you are using explicit pass through, you need a format that Terdata accepts, and chances are that they prefer a ISO date.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.