BookmarkSubscribeRSS Feed
Test_yes
Calcite | Level 5

Hi,

 

I have 3 dates and I am using INTCK function to find the no. months in between these 3 dates and and '01Feb2020'  as below:

 

data test;
a='09Mar2017'd;
b='30Dec2018'd;
c='13Jun2016'd;
d='01feb2020'd;
a1= INTCK('MONTH',a,d);
b1= INTCK('MONTH',b,d);
c1= INTCK('MONTH',c,d);
run;

If I count manually as below  I get 36 for the March 9, 2017 date similar to other 2 dates. But the function returns 35. I am not sure why.

 

December 30, 2018March 9, 2017June 13, 2016
January 30, 2019April 9, 2017July 14, 2016
March 2, 2019May 10, 2017August 14, 2016
April 2, 2019June 10, 2017September 14, 2016
May 3, 2019July 11, 2017October 15, 2016
June 3, 2019August 11, 2017November 15, 2016
July 4, 2019September 11, 2017December 16, 2016
August 4, 2019October 12, 2017January 16, 2017
September 4, 2019November 12, 2017February 16, 2017
October 5, 2019December 13, 2017March 19, 2017
November 5, 2019January 13, 2018April 19, 2017
December 6, 2019February 13, 2018May 20, 2017
January 6, 2020March 16, 2018June 20, 2017
February 6, 2020April 16, 2018July 21, 2017
 May 17, 2018August 21, 2017
 June 17, 2018September 21, 2017
 July 18, 2018October 22, 2017
 August 18, 2018November 22, 2017
 September 18, 2018December 23, 2017
 October 19, 2018January 23, 2018
 November 19, 2018February 23, 2018
 December 20, 2018March 26, 2018
 January 20, 2019April 26, 2018
 February 20, 2019May 27, 2018
 March 23, 2019June 27, 2018
 April 23, 2019July 28, 2018
 May 24, 2019August 28, 2018
 June 24, 2019September 28, 2018
 July 25, 2019October 29, 2018
 August 25, 2019November 29, 2018
 September 25, 2019December 30, 2018
 October 26, 2019January 30, 2019
 November 26, 2019March 2, 2019
 December 27, 2019April 2, 2019
 January 27, 2020May 3, 2019
 February 27, 2020June 3, 2019
  July 4, 2019
  August 4, 2019
  September 4, 2019
  October 5, 2019
  November 5, 2019
  December 6, 2019
  January 6, 2020
  February 6, 2020
5 REPLIES 5
bobpep212
Quartz | Level 8

Check out the fourth optional argument,  method: continuous or discrete. Discrete counts the interval boundary.

 

https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p1md4mx2crzfaqn14va8kt7qvfhr.htm...

bobpep212
Quartz | Level 8
I think I see what you mean...But it is about the count of movement between months - someone here will correct me. Sorry.
yabwon
Onyx | Level 15

Hi,
what value would you expect to have between "01feb2020"d and "01jan2020"d ?

 

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

 
 

image.png


All the best
Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Tom
Super User Tom
Super User
If you want N+1 instead of N why not just add one to the result?
Rick_SAS
SAS Super FREQ

I don't understand how your "count manually" column is created. Here is how you can see the months between 09Mar2017 and Feb 2020

data test;
a='09Mar2017'd;
d='01feb2020'd;
a1= INTCK('MONTH',a,d);
do i = 0 to a1;
   anniv = intnx('MONTH',a, i, 'same');
   output;
end;
format a d anniv DATE9.;
run;

proc print;run;

 

 

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
  • 5 replies
  • 551 views
  • 3 likes
  • 5 in conversation