Desktop productivity for business analysts and programmers

Prompt Manager and macros

Reply
N/A
Posts: 0

Prompt Manager and macros

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
Respected Advisor
Posts: 4,130

Re: Prompt Manager and macros

Just a theory:

Try: %put %str(&macroname);
Respected Advisor
Posts: 4,130

Re: Prompt Manager and macros

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
N/A
Posts: 0

Re: Prompt Manager and macros

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.
Respected Advisor
Posts: 4,130

Re: Prompt Manager and macros

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
Ask a Question
Discussion stats
  • 4 replies
  • 131 views
  • 0 likes
  • 2 in conversation