BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PaigeMiller
Diamond | Level 26

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_
monthof_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
1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

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;

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

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;

PaigeMiller
Diamond | Level 26

Okay, thank you, I see my silly error.

--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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