BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ayin
Quartz | Level 8

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:

Screenshot - Prompt Manager

Users will be required to select from the list. If he/she selects B & C:

Screenshot - Prompt Manager2

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?

1 ACCEPTED SOLUTION

Accepted Solutions
MichaelLarsen
SAS Employee

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;

 

View solution in original post

2 REPLIES 2
MichaelLarsen
SAS Employee

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;

 

ayin
Quartz | Level 8
Exactly what I need. Thank you so much!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 883 views
  • 1 like
  • 2 in conversation