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, 2018 | March 9, 2017 | June 13, 2016 |
| January 30, 2019 | April 9, 2017 | July 14, 2016 |
| March 2, 2019 | May 10, 2017 | August 14, 2016 |
| April 2, 2019 | June 10, 2017 | September 14, 2016 |
| May 3, 2019 | July 11, 2017 | October 15, 2016 |
| June 3, 2019 | August 11, 2017 | November 15, 2016 |
| July 4, 2019 | September 11, 2017 | December 16, 2016 |
| August 4, 2019 | October 12, 2017 | January 16, 2017 |
| September 4, 2019 | November 12, 2017 | February 16, 2017 |
| October 5, 2019 | December 13, 2017 | March 19, 2017 |
| November 5, 2019 | January 13, 2018 | April 19, 2017 |
| December 6, 2019 | February 13, 2018 | May 20, 2017 |
| January 6, 2020 | March 16, 2018 | June 20, 2017 |
| February 6, 2020 | April 16, 2018 | July 21, 2017 |
| May 17, 2018 | August 21, 2017 | |
| June 17, 2018 | September 21, 2017 | |
| July 18, 2018 | October 22, 2017 | |
| August 18, 2018 | November 22, 2017 | |
| September 18, 2018 | December 23, 2017 | |
| October 19, 2018 | January 23, 2018 | |
| November 19, 2018 | February 23, 2018 | |
| December 20, 2018 | March 26, 2018 | |
| January 20, 2019 | April 26, 2018 | |
| February 20, 2019 | May 27, 2018 | |
| March 23, 2019 | June 27, 2018 | |
| April 23, 2019 | July 28, 2018 | |
| May 24, 2019 | August 28, 2018 | |
| June 24, 2019 | September 28, 2018 | |
| July 25, 2019 | October 29, 2018 | |
| August 25, 2019 | November 29, 2018 | |
| September 25, 2019 | December 30, 2018 | |
| October 26, 2019 | January 30, 2019 | |
| November 26, 2019 | March 2, 2019 | |
| December 27, 2019 | April 2, 2019 | |
| January 27, 2020 | May 3, 2019 | |
| February 27, 2020 | June 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 |
Check out the fourth optional argument, method: continuous or discrete. Discrete counts the interval boundary.
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."
All the best
Bart
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.