BookmarkSubscribeRSS Feed
jdk123
Calcite | Level 5
the current_date='01feb2011'd;

how to identify the last month of the last quarter of the current data '01feb2011'd?

thanks,
3 REPLIES 3
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Jdk123,

month=MONTH(current_date);
qtr=INT(month/4)+1;

Is this what are you looking for?

Sincerely,
SPR
Olivier
Pyrite | Level 9
Hi.
If I do understand your need, you have to try the INTNX function (to shift 1 quarter back in the past) with the optional "END" fourth argument to move to the end of the period, that is the last day of the preceding quarter.
[pre]last_quarter_month = INTNX("QUARTER", current_date, -1, "END") ;[/pre]
This gives 31dec2010 for CURRENT_DATE to 01feb2011. If you only want the month, include the whole INTNX function into a MONTH function ; that will produce 12 as a result.
Hope it helps.
Olivier
jdk123
Calcite | Level 5
Thanks Oliver, you have been great help.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 895 views
  • 0 likes
  • 3 in conversation