BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Anandkvn
Lapis Lazuli | Level 10
data n;
lastmonth_endof_before_date=intnx('day',(today()-1)-1,'e');
format lastmonth_endof_before_date    date9.;
run;

how to get last month before date of end of the month 

ex: last month end is 31March2023 i am trying 30March2023 date

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Super User

Add a -1 to your expression. SAS Dates are just integers 🙂

View solution in original post

4 REPLIES 4
yabwon
Meteorite | Level 14
data _null_;
lastmonth_endof_before_date=intnx('month',today(),0,'e')-1;
put lastmonth_endof_before_date date9.;
run;
_______________
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



Anandkvn
Lapis Lazuli | Level 10
data n;
samedate=intnx('month',today(),0,'s');
prev_month=intnx('month',today(),-1,'s');
thismonth_begin=intnx('month',today(),0,'b');
nextmonth_begin=intnx('month',today(),1,'b');
prev_month_ending=intnx('month',today(),-1,'e');
next_month_ending=intnx('month',today(),1,'e');
last_2months=intnx('month',today(),-2);
lastmonth_endof_before_date=intnx('month',today(),-1,'e')-1;

format lastmonth_endof_before_date  last_2months next_month_ending samedate  thismonth_begin nextmonth_begin prev_month_ending prev_month:           date9.;
run;

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

yabwon
Meteorite | Level 14

right 🙂 but you get the point 🙂

_______________
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



PeterClemmensen
Super User

Add a -1 to your expression. SAS Dates are just integers 🙂

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 125 views
  • 2 likes
  • 3 in conversation