Hello guys, I want to use macro variables inside the put statement. When I use numbers it works perfectly, but when I replace numbers with macro variables, it doesn't work.
filename DDEcmds dde 'excel|system';
data _null_;
file DDEcmds;
put '[select("R2C%sysevalf(&id+3):R100C%sysevalf(&id+3)")]';
put '[Format.Number("#,##0")]';
run;
Hello @AlexeyS,
You can use double quotes and double double quotes to avoid the single quotes:
put "[select(""R2C%sysevalf(&id+3):R100C%sysevalf(&id+3)"")]";
Macro Variables don't resolve if they are within single quotes.
You are not resolving the macro code. To resolve macro code it needs to be within double quotes:
'[select("R2C%sysevalf(&id+3):R100C%sysevalf(&id+3)")]';
The double quotes here are within single quotes, therefore part of the text. Maybe something like.
data _null_; file DDEcmds; str=cats('[select(',"R2C%sysevalf(&id+3):R100C%sysevalf(&id+3)"),']'); put str; put '[Format.Number("#,##0")]'; run;
Again though, DDE is a dead technology, from 30 years + out of service.
Hello @AlexeyS,
You can use double quotes and double double quotes to avoid the single quotes:
put "[select(""R2C%sysevalf(&id+3):R100C%sysevalf(&id+3)"")]";
put '[select("R2C%sysevalf(&id+3):R100C%sysevalf(&id+3)")]';
The outermost single quotes prevent all macro trigger resolution.
Use an intermediate string:
length string $50;
string = '[select("R2C' !! "%sysevalf(&id+3):R100C%sysevalf(&id+3)" !! '")]';
put string;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.