BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Dear All,

I have set up a macro prompt in a project which is a text prompt which requires the user to enter a set of multiple values which have been obtained from an existing dataset. I have linked the prompt to a programme within the project successfully.

When I run the programme, the prompt comes up as expected. Now I choose say three elements from the list by checking the appropriate boxes. So far so good. However when I try and see what is in the macro by using the %PUT &macroname I only get the very first element of the macro returned. If I do %PUT macroname_count I get the answer 3 – so what has happened to the other 2 elements?

Thanks for any help


Best wishes, Chris
4 REPLIES 4
Patrick
Opal | Level 21
Just a theory:

Try: %put %str(&macroname);
Patrick
Opal | Level 21
Hi Chris

Got it now!

Have a look at your log. You'll see there a bunch of %symdel deleting numbered macros (macroname1, macroname2,...). Seems that's how the entered values get translated into SAS code.

You can also use "export Program.." and you'll see what's happening.

Here a code example how to list the values for a "multi input text prompt" called "prompt_multi_string".

%macro list_multi_string;
%do i=1 %to &prompt_multi_string_count;
%put prompt_multi_string&i= &&prompt_multi_string&i;
%end;
%mend;

%list_multi_string

HTH
Patrick
deleted_user
Not applicable
Thank you Patrick - that's exactly it. There is a corresponding odd problem it throws up when there is only one item in the list - it puts the text into a macro called macroname but not macroname1.
Patrick
Opal | Level 21
Hmm... that's ugly. One could almost call this a bug.

So the macro should be coded like this?

%macro list_multi_string;
%if &prompt_multi_string_count=1 %then
%put prompt_multi_string= &prompt_multi_string;
%else
%do i=1 %to &prompt_multi_string_count;
%put prompt_multi_string&i= &&prompt_multi_string&i;
%end;
%mend;
%list_multi_string

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1547 views
  • 0 likes
  • 2 in conversation