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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 854 views
  • 0 likes
  • 2 in conversation