Hello,
I have created a text prompt "Variable_List" with Multiple Values. I want to resolve this Text Type macro in my code.
Previously, I was using limited number of variables with manual input in the macro variable " varlist".
%let varlist = TBM_STAGE1 TBM_STAGE2 SHIFT_BUILD_DATE BLADDER;I was using the below format for count and then loop across these variables to get the output.
/*4.Looping through the Variables and checking the Data Type with Put Statement at the end*/
%do I=1 %to %sysfunc(countw(&varlist));
%let var = %scan(&varlist, &I);My question is I just have to Substitute the &varlist with &Variable_List. in the Do statement? Kindly let me know if you need further input.
SAS creates an additional variable named "Variable_List_Count" and sets it to the number of values selected. If more than one value was selected, than the values are in the variables "Variable_List1", "Variable_List2" ...
The following step should create the macro-variable varlist in the already used format.
data _null_;
length varList $ 1000;
do i = 1 to &Variable_List_Count.;
if i = 1 then do;
varlist = catx(' ', varList, symget("Variable_List"));
end;
else do;
varlist = catx(' ', varList, symget(cats("Variable_List", i)));
end;
end;
call symputx('varList', varList);
run;
SAS creates an additional variable named "Variable_List_Count" and sets it to the number of values selected. If more than one value was selected, than the values are in the variables "Variable_List1", "Variable_List2" ...
The following step should create the macro-variable varlist in the already used format.
data _null_;
length varList $ 1000;
do i = 1 to &Variable_List_Count.;
if i = 1 then do;
varlist = catx(' ', varList, symget("Variable_List"));
end;
else do;
varlist = catx(' ', varList, symget(cats("Variable_List", i)));
end;
end;
call symputx('varList', varList);
run;
Perfect!!! Thanks @andreas_lds for explaining the concept behind the work and the code is working exactly what I needed ![]()
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.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.