Using proc sql (passing teradata) I need to calculate the number of business days between two dates:
,intck('WEEKDAY', a.OPEN_DATE, b.DSCHRG_DT) as Num_BD_Diff (this did not work)
What is the correct code to use?
Thanks for any advice!
I can't help you on the Teradata side of things.
But, on the SAS side,
If both variables are received as datetimes use:
intck('DTWEEKDAY', a.OPEN_DATE, b.DSCHRG_DT)
if a.OPEN_DATE is a date and b.DSCHRG_DT is a datetime, use:
intck('WEEKDAY', a.OPEN_DATE, datepart(b.DSCHRG_DT))
and finally, if one of your variables is a character string, convert it to a SAS date using the PUT() function with the appropriate format for that string.
intck('WEEKDAY', PUT(a.OPEN_DATE, date9.), b.DSCHRG_DT)
Does work. If OPEN_DATE and DSCHRG_DT are dates. If one or the other is a datetime or a character string, it won't work.
I can't help you on the Teradata side of things.
But, on the SAS side,
If both variables are received as datetimes use:
intck('DTWEEKDAY', a.OPEN_DATE, b.DSCHRG_DT)
if a.OPEN_DATE is a date and b.DSCHRG_DT is a datetime, use:
intck('WEEKDAY', a.OPEN_DATE, datepart(b.DSCHRG_DT))
and finally, if one of your variables is a character string, convert it to a SAS date using the PUT() function with the appropriate format for that string.
intck('WEEKDAY', PUT(a.OPEN_DATE, date9.), b.DSCHRG_DT)
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.