@JamesBlack wrote:
Thank you, guys.
Your suggestions are useful in combination with my DATA step solution, which is good.
I was expecting something simpler, though. When I run:
%let want2 = left(put(month(&day_act.) + &i.,best.)); %put &want2.;
I get the string 'left(put(month(mdy(3,13,2018)) + -1,best.))'. It's also useful in my code, but this time I would like to have '2' returned. I tried RESOLVE etc. If there were something like that, it would make the code much simpler.
If you want to actually execute a data step function such as Month in a macro assignment every single function used has to be enclosed in a %sysfunc() call. %SYSFUNC macro function tells the SAS compiler to use the data step function. Otherwise you get text.
Also the macro language doesn't "like" the put statement and wants Putn(variable, format.)
%let want2 = %sysfunc( left(%sysfunc (putn( %sysfunc(month(&day_act.) ) + &i.,best.)) ) );
might work. Multiple function calls in statement gets very ugly quickly. Often I may be easier to use a data _null_ step and call symputx.
Note that there are a number of data step function that have macro equivalents such as Index/%index, Length/%Length, Scan /%scan
... View more