BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
xxformat_com
Barite | Level 11

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;

Capture.JPG

 

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.

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

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;

 

--
Paige Miller
Tom
Super User Tom
Super User

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.

 

mkeintz
PROC Star

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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 575 views
  • 2 likes
  • 4 in conversation