SAS Enterprise Guide

Desktop productivity for business analysts and programmers
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sharath_rk
Calcite | Level 5


Hello,

I am needing to calculate three business days from OE_DATE & DLVR_STRT_DATE and using the below i am getting three business days between order date & delivery date. however if an order is placed on tuesday then i am getting three business days as wed, thu, fri, sat & sun. I need the sat & sun excluded from the calc as it is > 3 business days. The issue is with orders having order date on tuesdays where the made orders have delivery date on wed, thu, fri, sat & sun where delivery date on sat, sun should be miss as it is > 3 business days. Please advise.

IF intck('WEEKDAY',OE_DATE,DLVR_STRT_DATE) LE 3                       then c = 'made'

else                                                                                                            c = 'miss';

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Did you try the code included?

expected_delivery=intnx('weekday', OE_DATE, 3);

if DLVR_STRT_DATE>expected_delivery then c='made';

else c='miss';

View solution in original post

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

As you are only looking at a few possibilities, maybe best to just do it with manual if statements, e.g.

If weekday(dlvr_strt_date)=1 then checkdt=dlvr_strt_date + 4; /* Sunday so Mon/Tues/Wed */

If weekday(dlvr_strt_date)=2 then checkdt=dlvr_strt_date + 3; /* Monday so Tues/Wed/Thurs */

...

If weekday(dvlr_strt_date)=6 then checkdt=dlvr_strt_date + 5;      /* Friday so wed */

...

If dlvr_strt_date <= oe_date <= checkdt then "made";

else "miss";

Note-can't check this at the moment.

Reeza
Super User

I am needing to calculate three business days from OE_DATE & DLVR_STRT_DATE

Do you need to calculate the business day that is 3 days away from each of the date above?

Or if the duration between the two dates is greater than 3 days?

Try using intnx to calculate the 3 day delivery date and check if delivery date is after that date.

expected_delivery=intnx('weekday', OE_DATE, 3);

if DLVR_STRT_DATE>expected_delivery then c='made';

else c='miss';

sharath_rk
Calcite | Level 5

made = OE_DATE + 3 business days should be less than equal to DLVR_STRT_DATE minus weekends. Please advise.

for example : OE_DATE = Tuesday + 3 business days ( wed, thu, fri ) less than equal to DLVR_STRT_DATE then c='made';

else c='miss';

the below logic works for all days except tuesday where made orders are from wed, thu, fri, sat & sun.

IF intck('WEEKDAY',OE_DATE,DLVR_STRT_DATE) LE 3                       then c = 'made'

else                                                                                                            c = 'miss';

Reeza
Super User

Did you try the code included?

expected_delivery=intnx('weekday', OE_DATE, 3);

if DLVR_STRT_DATE>expected_delivery then c='made';

else c='miss';

sharath_rk
Calcite | Level 5

It worked Smiley Happy Thank you very much.

sharath_rk
Calcite | Level 5

The duration between two date columns should be LE 3 business days.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2000 views
  • 0 likes
  • 3 in conversation