Solved
Contributor
Posts: 41

# intck day365

data _null_;
days365=intck('day365','31dec2009'd,'19dec2010'd);
put days365 = ;
run;

results : day365 = 1

Why 1 is coming. since intervel is not 365. it should be come as 0.

Can someone explain pls.

Accepted Solutions
Solution
‎05-04-2016 09:13 AM
SAS Super FREQ
Posts: 825

## Re: intck day365

Hi

As to the why, I do not know. However if you change your code to use the CONTINUOUS method, it should work as you expect. The CONTINUOUS sets that starting date as the beginning of the interval. See also the INTCK function.

``````data _null_;
days365=intck('day365', '31dec2009'd, '19dec2010'd, "CONTINUOUS");
put days365 =;
run;``````

Bruno

All Replies
Solution
‎05-04-2016 09:13 AM
SAS Super FREQ
Posts: 825

## Re: intck day365

Hi

As to the why, I do not know. However if you change your code to use the CONTINUOUS method, it should work as you expect. The CONTINUOUS sets that starting date as the beginning of the interval. See also the INTCK function.

``````data _null_;
days365=intck('day365', '31dec2009'd, '19dec2010'd, "CONTINUOUS");
put days365 =;
run;``````

Bruno

Contributor
Posts: 41

Thanks a lot bro

attachments. -##
Posts: 1,250

## Re: intck day365

[ Edited ]

Hi @vandhan,

As to the why: I found the explanation in section "Multi-Unit Intervals" of the documentation About Date and Time Intervals:

"For all multi-unit intervals except multi-week intervals, SAS creates an interval beginning on January 1, 1960, and counts forward from that date to determine where individual intervals begin on the calendar."

Together with the fact that the default "method" (the last, optional argument) of INTCK is "DISCRETE", this means that the result is obtained by counting the interval boundaries between start date and end date.

Obviously, as '19dec2010'd - '31dec2009'd = 353 <= 365, there can be at most one boundary of consecutive 365-days intervals (regardless of where they start) between the two dates.

`'19dec2010'd = 18615 = 51*365`

Since January 1, 1960, is SAS day 0, the above equation means that (the) one interval boundary is the boundary between the days 18 Dec 2010 and 19 Dec 2010. Hence intck('day365','31dec2009'd,'19dec2010'd)=1, whereas intck('day365','31dec2009'd,'18dec2010'd)=0.

The "discrepancy" 365 - 353 = 12 reflects just the number of leap years after 1960 up until 2010. (The first of those fifty-one 365-days intervals ended on 30 Dec 1960, so that the first incrementation of the count occurs with '31Dec1960'd.)

The good thing about the CONTINUOUS method suggested by @Bruno_SAS is that the "interval is shifted based on the starting date" (INTCK documentation) and not based on the arbitrary 1 Jan 1960.

🔒 This topic is solved and locked.