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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 6 replies
  • 1113 views
  • 0 likes
  • 3 in conversation