BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vandhan
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

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

View solution in original post

3 REPLIES 3
BrunoMueller
SAS Super FREQ

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

vandhan
Fluorite | Level 6
Thanks a lot bro

##- Please type your reply above this line. Simple formatting, no
attachments. -##
FreelanceReinh
Jade | Level 19

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1517 views
  • 3 likes
  • 3 in conversation