I have the following filter:
WHERE t1.flightdate >= intnx('Month',today(),-&months_back)
so if &months_back is 3, I will get data from all of June, July, and August of this year.....but it will also include September. I do not want September...I only want the last number of FULL months as identified with the macro variable &months_back. What filter can I add to get rid of the partial month dates?
WHERE t1.flightdate >= intnx('Month',today(),-&months_back) and t1.flightdate < intnx('month', today(), 0, 'b');
Same idea, use INTNX() to get current months first day (interval = 0, aligment = b) and use BETWEEN or < for the date.
@BCNAV wrote:
I have the following filter:
WHERE t1.flightdate >= intnx('Month',today(),-&months_back)
so if &months_back is 3, I will get data from all of June, July, and August of this year.....but it will also include September. I do not want September...I only want the last number of FULL months as identified with the macro variable &months_back. What filter can I add to get rid of the partial month dates?
SAS supports structures like
Where value1 < value2 < value3
So add the other constraint
WHERE somevalue > t1.flightdate >= intnx('Month',today(),-&months_back)
perhaps
where intx('month',today(),0,'B') > t1.flightdate >= intnx('Month',today(),-&months_back)
if you only want dates prior to the beginning of the current month.
where intnx('Month',today(),-3)<=date<=intnx('Month',today(),-1,'e');
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.