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.
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
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
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 @BrunoMueller is that the "interval is shifted based on the starting date" (INTCK documentation) and not based on the arbitrary 1 Jan 1960.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.