BookmarkSubscribeRSS Feed
Tom
Super User Tom
Super User

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

2 REPLIES 2
DonH
Lapis Lazuli | Level 10

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.

AngelaHall
SAS Employee

Tom,

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

Angela

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 1785 views
  • 6 likes
  • 3 in conversation