BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8

 

data test;
result1=intck("month", "14Nov2021"d, "24jan2022"d);
result3=intck("month", "7sep2021"d, "01dec2021"d);
result3=intck("month", "20sep2021"d, "01dec2021"d); run; proc print data=test; run;

how is the no of month calculated, is it round up or round down and where is the dividing line? 

2 REPLIES 2
SASKiwi
PROC Star

No rounding is done with the default behaviour of the INTCK function which is to count month boundaries. In your first example 14Nov2021 to 24Jan2022, this crosses two month boundaries (1 Dec 2021 and 1 Jan 2022) so RESULT1 = 2.

 

EDIT: If you add the continuous option then the results change. Try this:

data _null_;
result1=intck("month", "14Nov2021"d, "14Jan2022"d, 'C');
result2=intck("month", "14Nov2021"d, "13Jan2022"d, 'C');
result3=intck("month", "14Nov2021"d, "15Jan2022"d, 'C');
put _all_;
run;

SAS now counts complete months from the starting date. RESULT1 = 2 as 14 Nov to 14 Jan is 2 complete month intervals exactly. RESULT2 = 1 as only 1 month interval is complete. RESULT3 = 2 as it contains 2 complete month intervals - the extra day is not included.

Kurt_Bremser
Super User

From the documentation of the INTCK Function:

 

Returns the number of interval boundaries of a given kind that lie between two dates, times, or datetime values.

 

With an interval of MONTH, the boundary is midnight between the last day of a month and the first day of the following month.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 389 views
  • 2 likes
  • 3 in conversation