BookmarkSubscribeRSS Feed
Lopes
Calcite | Level 5

Hi!

I need to get the last day of the month using the basedate.

I tried with the intnx('month',basedate,i, 'same'). If the basedate=30Apr2014 then the next month is 30May2014, but I need it to be 31May2014.

I appreciate if you can help me with it.

Thanks and kind regards,

Paula

3 REPLIES 3
Reeza
Super User

RTM

for the aligment use END rather than SAME:

SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition

'alignment'

controls the position of SAS dates within the interval. You must enclose alignment in quotation marks. Alignment can be one of these values:

BEGINNING

specifies that the returned date or datetime value is aligned to the beginning of the interval.

Alias:B
MIDDLE

specifies that the returned date or datetime value is aligned to the midpoint of the interval, which is the average of the beginning and ending alignment values.

Alias:M
END

specifies that the returned date or datetime value is aligned to the end of the interval.

Alias:E
SAME

specifies that the date that is returned has the same alignment as the input date.

Alias:S
Alias:SAMEDAY
See:SAME Alignment for more information.
Lopes
Calcite | Level 5

Thank you very much!

Is working now. Thanks!

Peter_C
Rhodochrosite | Level 12

%let nextmonthend =%sysfunc( intnx( month, "&sysdate9"d, 1, e), date9 ) ;

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

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3 replies
  • 1892 views
  • 0 likes
  • 3 in conversation