Hi All,
I m trying to do sas date function using sas macro and i need below output.
%let a= %sysfunc(intnx(day,%sysfunc(today()),-1),yymmdd10.);
Output
2017-10-26.
but need output should be .
'2017-10-26'
within the code.
Please guide me how would be do it.
data _null_;
date=today()-1;
format date yymmdd10.;
put date;
run;
Where do you use the macro variable? Depending on the use, both the format and the quotes might not be necessary.
If you have to do this in macro, you could precede and follow you expression with %str(%'), as in:
%let a= %str(%')%sysfunc(intnx(day,%sysfunc(today()),1),yymmdd10.)%str(%');
%put &=a;
Personally I'm not a fan of including quotes in macro variables, I prefer to leave them unquoted and then use with quotes as necessary. It makes them more versatile in the long run and allows for multiple uses.
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.
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.