Solved

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

Posted on 2011-03-21
3
2,969 Views
Last Modified: 2013-11-16
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.
0
Comment
Question by:murach
3 Comments
 
LVL 11

Accepted Solution

by:
theartfuldazzler earned 250 total points
ID: 35186832
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
 
LVL 7

Assisted Solution

by:d507201
d507201 earned 250 total points
ID: 35189456

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 Closing Comment

by:murach
ID: 35190150
Thanks, both.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now