Hi there.
I have a data set where the dates are stored as character so i use a substring to retrieve the data
Where = (substr(CaseCreatedDateTime,1,7) in ("2018-09","2018-08")));
The dates need to change each month to the current month and previous month so i'm trying to teach myself to do it in a macro.
data test;
format Temp_TM Temp_LM DDMMYY10.;
Temp_TM=Today();
Temp_LM=intnx('month',Temp_TM,-1,'b');
month=put(month(Temp_TM),z2.);
ThisMonth1=cat((Year(Temp_TM)),"-",(put(Month(Temp_TM),z2.)));
LastMonth1=cat((Year(Temp_LM)),"-",(put(Month(Temp_LM),z2.)));
run;
which gives me two variables with the year and month in in the format above however when i try to reference them sas is seeing it as numeric so it wont work.
Where = (substr(CaseCreatedDateTime,1,7) in (&This_Month,&Last_Month);
i think i need to add quotes around the dates in the macro but am struggling to do it.
Any help greatly appreciated.
Stret
jesus i've overthought that just a little haven't i.
Thank you for your help
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.