# In SAS, is there a NETWORKDAYS function (like in Excel)?

In Excel, there is a NETWORKDAYS function (that calculates the Net number of Working Days between two dates, excluding weekends and optionally, a user-data-range of holiday dates).  Is there a similar function in SAS?

Thanks.
###### Who is Participating?

Commented:
Hi

I don't know of a way to use user-defined holidays.  However, if you want to calculate the number of days between two dates, excluding weekends, you can use the INTCK function with the WEEKDAY interval:

DATA Test;
Date1 = '01Jan2011'd;
Date2= '31Dec2011'd;

Days1 = INTCK("WEEKDAY" , Date1, Date2);   /*  Num days excluding Sat and Sun */
Days2 = INTCK("WEEKDAY561W" , Date1, Date2); /*  Num days excluding Fri, Sat and Sun */
PUT Days1= Days2=;
RUN;
0

Database Marketing ConsultantCommented:

Put a list of holidays into an array.  Then after using the INTCK to calculate number_of_days loop thru the array and subtract 1 for each holiday found.

array holidays {*} ('01jan2011'd '26dec2011'd);

do n=1 to dim(holidays);
if date1 le holidays{n} le date2 then days1=days1-1;
end;

drop n;

Here's the officiial list of federal holidays -- http://www.opm.gov/Operating_Status_Schedules/fedhol/2011.asp

Here's a list of holidays that includes fun holidays Fat Tuesday and Mother's Day --
http://en.wikipedia.org/wiki/List_of_holidays_by_country#United_States_of_America
0

Author Commented:
Thanks, both.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.