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
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.