Hi,
I understand the weekday interval in intnx function but given that I don't have experience in finance, I cannot really figure out when it is useful.
Would you have an explaination for dummies.
Let's take an example. September 18th is a Monday.
By default, the weekday interval uses Saturday and Sunday as weekends.
Each day going from Monday to Thursday starts and ends on the same day.
The interval of any date between Friday and Sunday starta on the Friday and enda on the Sunday.
data demo (drop=i);
do i=1 to 7;
_date='18SEP2022'd+i;
output;
end;
run;
data demo;
set demo;
_weekday_b=intnx('weekday',_date,0,'b');
_weekday_e=intnx('weekday',_date,0,'e');
run;
proc print data=demo noobs;
format _date _week: weekdate.;
run;
My guess: when there is no change on the weekend, people might just want their programs to keep running as if it was on Friday. Saturday and Sunday reports would be like Friday reports.
Happy to hear any more valuable concrete explainations.
You ask about finance implications of intnx('weekday').
Stock markets report opening and closing stock prices on trading days - generally equivalent to the "weekday" interval. So if you have date-stamped stock values, you can relatively reliably count the number of trading days between a couple of dates using the INTCK('weekday',...) function.
Often stock price analysis is done that involves comparing daily close to next daily open. But Friday close to Monday open is a longer time, exposed to more news, or other events - some of which might be intentionally timed, others not.
I wouldn't be surprised if one found a greater "overnight" variance in stock prices for Fridays-to-Mondays vs all other overnight variances.
INTNX and INTCK are functions that count date or time periods. When the first argument is WEEKDAY, it counts weekdays.
data have;
today='08SEP2022'd;
five_weekdays_from_today=intnx('weekday',today,5,'s');
twelve_weekdays_from_today=intnx('weekday',today,12,'s');
format today five_weekdays_from_today twelve_weekdays_from_today date9.;
run;
The NEXT weekday after FRIDAY is MONDAY.
I wouldn't worry about the BEGINNING and ENDING for understanding week days, concept does not really apply in the same way as for normal interval, like a MONTH or a YEAR.
You ask about finance implications of intnx('weekday').
Stock markets report opening and closing stock prices on trading days - generally equivalent to the "weekday" interval. So if you have date-stamped stock values, you can relatively reliably count the number of trading days between a couple of dates using the INTCK('weekday',...) function.
Often stock price analysis is done that involves comparing daily close to next daily open. But Friday close to Monday open is a longer time, exposed to more news, or other events - some of which might be intentionally timed, others not.
I wouldn't be surprised if one found a greater "overnight" variance in stock prices for Fridays-to-Mondays vs all other overnight variances.
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 25. 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.