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)
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: