turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- intck day365

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-04-2016 07:12 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to vandhan

05-04-2016 08:14 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to vandhan

05-04-2016 08:14 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Bruno_SAS

05-04-2016 09:14 AM

Thanks a lot bro

##- Please type your reply above this line. Simple formatting, no

attachments. -##

##- Please type your reply above this line. Simple formatting, no

attachments. -##

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to vandhan

05-04-2016 02:01 PM - edited 05-04-2016 02:17 PM

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,'**18**dec2010'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.