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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.