05-21-2015 03:03 PM
I am trying to find out the number of working days in month using INTCK but getting incorrect result??
I have used the below code, but it gives me correct result for one month but incorrect for other.
days=intck("weekday", this_month_first_date, next_month_first_date);
format this_month_first_date next_month_first_date date9.;
proc print data=kbc;
I have one doubt also that intnx function I used above is also counting the days: this_month_first_date, next_month_first_date + days between them for total numbers days in month. What I have studied is that intnx function calculates the time interval b/w two date/time value but it also include that two date/time is in doubts
05-21-2015 03:49 PM
if you want to figure out number of days you would put 'day' not 'month'. BUT, as I've seen pointed out in this forum before you only have to subtract date from date to get the difference in days, no function is necessary. If this doesn't help give an example dataset and an example of what you want.
05-21-2015 04:01 PM
First would be to define what you mean by working days. Are holidays excluded? Which ones? Is the holiday actually observed on that date when it occurs on a Saturday or Sunday?
Note that there is a Holiday function for US and some Canadian holidays.
05-21-2015 04:10 PM
Is below what you're after? SAS(R) 9.4 Language Reference: Concepts, Fourth Edition
format start_dt end_dt date9.;
If you need to exclude holidays as well then you will likely have to create a custom interval. There have already been multiple discussions around this here in these forums so I suggest you do a search.
05-21-2015 04:39 PM
Try this. I think you have to set your start date as the last date of the previous month otherwise it is excluded from consideration, for example to get the correct number of calendar days in the month.
month = '01mar2015'd;
start = intnx('MONTH', month, -1, 'E');
end = intnx('MONTH',month, 0, 'E');
format month start end date9.;
weekdays = intck('WEEKDAY',start , end);
days = intck('DAY',start , end);