Your SAS programs, embedded in web apps and elsewhere

How to handle multiple selection prompts

Super User
Super User
Posts: 6,500

How to handle multiple selection prompts

Cynthia wrote a very nice description of how multiple selection prompts are converted to global macro variables for stored processes over on this thread.

It makes me wonder if anyone has suggestions on best processes for handling this to make coding of the stored process easier.

For example to me the fact that the first value selected might be in &MVAR or &MVAR1 or there might not even be a global macro variable defined should be straightened out before I can get to writing my program logic.

Thinking about it quickly I am up with this simple data step to make sure that the macro variable is defined.

I wonder what others are doing.  Or how to adapt it so that it also handles the variation of which macro variables are created when using SAS/Intrnet or EG instead of stored processes.

Just set the root macro variable name in the variable MVAR and the default value you want in the variable DEFAULT.  This example shows who to use %STR( ) to allow setting the default to a single space instead of an empty macro variable.

%let country_count=0;

data _null_;


  default='%str( )';


  call symputx(cats(mvar,'0'),count);

  if count<1 then call symputx(mvar,default);

  if count<2 then call symputx(cats(mvar,'1'),symget(mvar));


%put country="&country" _count="&country_count" 0="&country0" 1="&country1" ;

Frequent Contributor
Posts: 148

Re: How to handle multiple selection prompts


Check out the multipleNames macro which I posted to

The article includes the source and the comments talk about the fact that its origin was for the SAS/IntrNet Application Dispatcher, specifically my SAS Press book:

But it also works for the Stored Process Server.

I use it all the time for parameters that can have multiple values.

SAS Employee
Posts: 238

Re: How to handle multiple selection prompts


You could also grab the %_eg_whereparam macro code from Enterprise Guide and leverage that in stored processes.


Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation