Originally used codes to create a macro variable:
%let class = A B C;
%global class;Now tried to use Prompt Manager to achieve the same result above:
Users will be required to select from the list. If he/she selects B & C:
Then the value for the macro variable 'class', I hope, is "B C".
Clearly the Log shows:
8 %LET class0 = %nrstr(2);
9 %LET class1 = %nrstr(B);
10 %LET class2 = %nrstr(C);
11 %LET class_count = %nrstr(2);
12 %LET class = %nrstr(B);which is not what I need.
How to fix it?
You will need a macro to resolve the user selections into a single macro variable.
I have created a macro function the will resolve the values for you.
You may want to enhance it, using %symexist, to check if the specified macro varable actually exists.
%macro GetPromptValues(
promptvar /* Name of the macro variable containing the prompt selections */);
%let SelectedValues=;
%do i=1 %to &&&promptvar._COUNT;
%let SelectedValues=&SelectedValues &&&promptvar.&i;
%end;
&SelectedValues
%mend;
%let NewClass=%GetPromptValues(Class);
%put NewClass=&NewClass;
You will need a macro to resolve the user selections into a single macro variable.
I have created a macro function the will resolve the values for you.
You may want to enhance it, using %symexist, to check if the specified macro varable actually exists.
%macro GetPromptValues(
promptvar /* Name of the macro variable containing the prompt selections */);
%let SelectedValues=;
%do i=1 %to &&&promptvar._COUNT;
%let SelectedValues=&SelectedValues &&&promptvar.&i;
%end;
&SelectedValues
%mend;
%let NewClass=%GetPromptValues(Class);
%put NewClass=&NewClass;
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.