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.
data kbc;
this_month_first_date=intnx('month',today(),0,'b');
next_month_first_date=intnx('month',today(),1,'b');
days=intck("weekday", this_month_first_date, next_month_first_date);
format this_month_first_date next_month_first_date date9.;
run;
proc print data=kbc;
run;
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
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.
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.
Is below what you're after? SAS(R) 9.4 Language Reference: Concepts, Fourth Edition
data sample;
format start_dt end_dt date9.;
start_dt=intnx('month',today(),0,'b');
end_dt=intnx('month',start_dt,0,'e');
working_days=intck('WEEKDAY',start_dt,end_dt);
output;
stop;
run;
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.
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.
data _null_;
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);
put _all_;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.