[blue]I need to calculate 'working days' for clients. This is defined as the number of days between today() and an admission date -- excluding Saturdays and Sundays.
Sure they have the INTCK function. Why not just do simple subtraction.
data step;
set your_ds;
today = date();
days = today - sub_date; ***SUB_DATE IS YOUR SUBMISSION DATE IN SAS DATE FORMAT (N).;
run;
The var DAYS will be the number of days in the time span. It gets tricky if your date is before 1/1/1960. In that case use the function I mentioned.
Klaz2002
I hope this helps you.
[blue]I don't think INTCK will do it. INTCK will return the number of 'Day Intervals' between to dates. I can get the same value by substracting my two dates. Following an example from SAS, I tested the following:
This purports to count only weekdays (i.e., knocks off two days for every week between the two dates). The problem is that it will substract two days for every week even if only one weekend day occured within the timespan. For example, Sunday (9/7/03) to Friday (9/12/03) returns 5 Days; Saturday (9/6/03) to Friday (9/12/03) returns 4 Days (even though the start date is one less. This must be because you don't get credit for a week until you hit both Saturday and Sunday.
It's still a useful function, but doesn't give me what I need (or, more specifically, doesn't give me what I need for a small percentage of the records).
How about using a Weekday function on AddmissionDate and see if it is 1,or 7 which is (Saturday or Sunday).. the code could be something like this.. I haven't tested the code though.....
data t;
set dsn.indst;
noofDays=intck('day',AdmissionDate,today());/**Get No. of Days**/
WorkingDays=0;
%macro wrkDay;
%do i=1 to NoOfDays;
if weekday(AdmissionDate) not in(1,7,.) then
WorkingDays=WorkingDays+1;
AdmissionDate=AdmissionDate+1;
%end;
%mend WrkDay;
%WrkDay;
run;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.