DATA Step, Macro, Functions and more

sas function

Reply
Occasional Contributor
Posts: 18

sas function

the current_date='01feb2011'd;

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

thanks,
Super Contributor
Super Contributor
Posts: 365

Re: sas function

Hello Jdk123,

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

Is this what are you looking for?

Sincerely,
SPR
Super Contributor
Posts: 260

Re: sas function

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
Occasional Contributor
Posts: 18

Re: sas function

Thanks Oliver, you have been great help.
Ask a Question
Discussion stats
  • 3 replies
  • 179 views
  • 0 likes
  • 3 in conversation