Solved
Posts: 3,054

# INTNX using interval R445MON not giving expected results

Here's my code

data a;

today=mdy(1,1,2015);

do month=1 to 12;

start_of_month=intnx('r445mon',today,month-1,'s');

end_of_month=intnx('r445mon',today,month-1,'e');

output;

end;

format start_of_month end_of_month date7.;

drop today;

run;

proc print data=a noobs;

run;

which produces the following output, note that I would have expected the end_of_month to be one day before the start of the next month, but month 1 ends on 25JAN15 and month 2 starts on 29JAN15. Why is that? How can I fix this?

 start_ end_of_ month of_month month

 1 01JAN15 25JAN15 2 29JAN15 22FEB15 3 26FEB15 29MAR15 4 02APR15 26APR15 5 30APR15 24MAY15 6 28MAY15 28JUN15 7 02JUL15 26JUL15 8 30JUL15 23AUG15 9 27AUG15 27SEP15 10 01OCT15 25OCT15 11 29OCT15 22NOV15 12 26NOV15 03JAN16
--
Paige Miller

Accepted Solutions
Solution
‎08-03-2015 04:21 PM
Super User
Posts: 3,920

## Re: INTNX using interval R445MON not giving expected results

If you read the definition of the interval: R455MON:

Months that start on the 1st, 5th,9th, 14th, 18th,22nd, 27th, 31st,35th, 40th, 44th,and 48th Monday of the year. The 1st Monday is the Monday on or immediately preceding January 4th.

If you start your program on the 1st Monday of the year which is 29 Dec 2014 then you will get the expected result with the S option which means SAME not start. If you start with another date then use B for BEGINNING:

data a;

today=mdy(1,1,2015);

do month=0 to 11;

start_of_month=intnx('r445mon',today, month,'b');

end_of_month=intnx('r445mon',today, month,'e');

output;

end;

format start_of_month end_of_month date9.;

run;

proc print data=a noobs;

run;

All Replies
Solution
‎08-03-2015 04:21 PM
Super User
Posts: 3,920

## Re: INTNX using interval R445MON not giving expected results

If you read the definition of the interval: R455MON:

Months that start on the 1st, 5th,9th, 14th, 18th,22nd, 27th, 31st,35th, 40th, 44th,and 48th Monday of the year. The 1st Monday is the Monday on or immediately preceding January 4th.

If you start your program on the 1st Monday of the year which is 29 Dec 2014 then you will get the expected result with the S option which means SAME not start. If you start with another date then use B for BEGINNING:

data a;

today=mdy(1,1,2015);

do month=0 to 11;

start_of_month=intnx('r445mon',today, month,'b');

end_of_month=intnx('r445mon',today, month,'e');

output;

end;

format start_of_month end_of_month date9.;

run;

proc print data=a noobs;

run;

Posts: 3,054

## Re: INTNX using interval R445MON not giving expected results

Okay, thank you, I see my silly error.

--
Paige Miller
🔒 This topic is solved and locked.

Discussion stats
• 2 replies
• 231 views
• 0 likes
• 2 in conversation