I have a macro variable which I first need to convert it to a number and do some mathematical calculation, then I have to cover it with a single quote and bracket.
%let num1= 1000;
%let num2= 1000 - 100;
%let output = ('&num1.','&num2.');
I need output like this:
('1000','900')
I found the solution:
%let num1 = '1000';
%let num2 = %sysevalf(%sysfunc(compress(&num1.,"'"))-10);
%let output = (&num1.,%tslit(&num2.));
%put &num1.;
%put &num2.;
%put &output.;
I found the solution:
%let num1 = '1000';
%let num2 = %sysevalf(%sysfunc(compress(&num1.,"'"))-10);
%let output = (&num1.,%tslit(&num2.));
%put &num1.;
%put &num2.;
%put &output.;
%let num1= 1000;
%let num2= 1000 - 100;
%let output = (%bquote('&num1.','%eval(&num2.)'));
%put &output ;
Hey Xia @Ksharp
I know too well that you are intelligent. But unfortunately i am not,so
Can you please give me a hand to help my understanding if you have a couple of mins
Does the %bquote here force macro resolution inside '&var' and then quote the value? Is this behavior consistent?
I am keen to understand how the macro processor works here.
Sorry for the bother if you are busy
Hi. Thanks everything you do for sas communitity.
"Does the %bquote here force macro resolution inside '&var' and then quote the value? Is this behavior consistent?"
Answer is no. As far as I know %bquote firstly mask single quote , since quote has been masked ,then resolving macro variable & var is nature thing ,as %let x=&var ; .did .
Hope this could give you some hint .
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.