Hi All
I am trying to create a macro variable with value formed by concatenate symbol ("+" ) to a text string.
for example i need to create the following, attaching "+" based on iterations (4 times) and store it in a macro variable.
"test++++"
Thanks for all the help.
You mean this ?
%macro x;
%let x=test;
%do i=1 %to 3;
%let x=&x+;
%end;
%put &x;
%mend;
%x
Is what you want as simple as this?
%let macvar = test%sysfunc(repeat(+, 3));
%put &=macvar;
The repeat function takes the first parameter and repeats it n times.
Here a coding example if you want to do it inside of a data step:
data _null_;
length combined $50.;
base = "Hello";
combined = cat(base,repeat("+",3));
call symput("plusString",combined);
run;
%put &plusString;
You mean this ?
%macro x;
%let x=test;
%do i=1 %to 3;
%let x=&x+;
%end;
%put &x;
%mend;
%x
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.