03-31-2012 12:39 PM
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.
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" ;
04-06-2012 10:28 AM
Check out the multipleNames macro which I posted to sasCommunity.org:
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.