Your SAS programs, embedded in web apps and elsewhere

How to handle multiple selection prompts

Reply
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.

https://communities.sas.com/message/121828#121828

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_;

  mvar='country';

  default='%str( )';

  count=input(symget(cats(mvar,'_count')),best.);

  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));

run;

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

Frequent Contributor
Posts: 148

Re: How to handle multiple selection prompts

Tom,

Check out the multipleNames macro which I posted to sasCommunity.org:

http://www.sascommunity.org/wiki/The_multipleNames_Macro

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:

http://www.sascommunity.org/wiki/Building_Web_Applications_with_SAS/IntrNet:_A_Guide_to_the_Applicat...

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

Tom,

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

Angela

Ask a Question
Discussion stats
  • 2 replies
  • 462 views
  • 6 likes
  • 3 in conversation