BookmarkSubscribeRSS Feed
sharath_rk
Calcite | Level 5

Please assist.I could not use INTCK function as there's only one column from which i need the calculation to start if the day is weekday. 

9 REPLIES 9
LinusH
Tourmaline | Level 20

Sorry, I don't understand your issue.

Please post some sample input and desired output data.

Data never sleeps
sharath_rk
Calcite | Level 5

Hi,

Please see the two columns below. Column 2 is a calculated field which should show as Y for weekday and N for weekend/holiday. However it is showing as Y for 25th & 26th Jan which are weekends. How do i exclude weekends before i start the calculation.

Column 1Column 2
25JAN2014:00:06:13.000000Y
25JAN2014:00:08:32.000000Y
25JAN2014:00:14:15.000000Y
25JAN2014:00:18:39.000000Y
25JAN2014:00:18:40.000000Y
26JAN2014:14:58:33.000000Y
26JAN2014:14:58:47.000000Y
26JAN2014:14:59:18.000000Y
26JAN2014:15:01:15.000000Y
27JAN2014:00:01:10.000000Y
27JAN2014:00:03:46.000000Y
27JAN2014:00:00:00.000000Y
27JAN2014:00:00:00.000000Y
28JAN2014:00:00:00.000000Y
28JAN2014:00:00:00.000000Y
28JAN2014:00:00:00.000000Y
28JAN2014:00:00:00.000000Y
29JAN2014:00:00:00.000000Y
29JAN2014:00:00:00.000000Y
29JAN2014:00:00:00.000000Y
30JAN2014:00:00:00.000000Y
30JAN2014:00:00:00.000000Y
30JAN2014:00:00:00.000000Y
LinusH
Tourmaline | Level 20

Ok, if you are relying on US holidays, use the holiday() function.

If not, you need some kind of calendar data set/user defined format to handle holidays outside the US.

Data never sleeps
sharath_rk
Calcite | Level 5

Thanks. How can i exclude weekends from the colum 1 having date & time?

LinusH
Tourmaline | Level 20

Depending on your final technique, but usually involving the datepart() function can be of help.

Data never sleeps
Amir
PROC Star

Hi,

Further,  the weekday() function returns a day number (1-7) which you can test to exclude weekends.

SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition

Regards,

Amir.

ChrisHemedinger
Community Manager

If you're looking for a way to calculate "working days" (calendar days minus weekends and holidays), perhaps you can use this custom networkdays function:

Calculating the number of working days between two dates - The SAS Dummy

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
sharath_rk
Calcite | Level 5

That worked. Thank you Amir.

Chris,

That would be my next step. Will check the custom networkdays function. Thank you.

Regards

Sharath

rcwright
Calcite | Level 5

Take a look at the WeekDay() function. Give a date value, it returns 1-7, where 1=Sunday, 7=Saturday indicating the day of the week

To convert from Date-Time, use the DatePart() function,

So,

isweekday = (WeekDay(DatePart(dtvalue)) IN (2..6)); * think I got the parens right ;

returns, 0 (false), or 1(true).

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
  • 9 replies
  • 1397 views
  • 0 likes
  • 5 in conversation