Your SAS programs, embedded in web apps and elsewhere

Input parameters Validation Check before run the job

Reply
Occasional Contributor
Posts: 18

Input parameters Validation Check before run the job

Hello!
I have many input stored process parameters already defined in a stored process in multiple groups. I don't have all of them required to input by the user. But atleast one parameter is required to run the stored process smoothly.

So can we check atleast one parameter value is entered before submitting the Stored process to run? Is there any validation allowed in defining them before going to the server?

If the stored process is invoked only in web, we can add some java script functionality and can do validation part. But my stored proc mostly invoked by MS office applications.

Thanks in advance!
Raja
SAS Super FREQ
Posts: 8,864

Re: Input parameters Validation Check before run the job

If you marked at least one of the input parameters as REQUIRED, then at least THAT parameter would have to be provided in order for the stored process to run. If you have default values for the other parameters, then the default value would be used if they did NOT pick any choice for the other parameters.

Of course, once your stored process starts to execute on either the Stored Process server or the Workspace server, you could have SAS Macro programming logic (in a macro program) change the values of the parameters if the combination of unset parameter default values do not make sense. Something like:
[pre]
%global type place mytitle;
/* define the CKPARM macro program "instream" */

%macro ckparm;
/* These 2 parm values are incompatible */
%if (&type = ALL and
&place= Europe) %then %do;
%let type = Europe;
%let mytitle = Report for &place;
%end;
%else %if &type = ALL and
&place= %then %do; /* no selection for PLACE */
%let place= ALL; /* set value for PLACE to ALL */
%let mytitle = Report for All Countries;
%end;
%mend ckparm;

/* Now invoke the ckparm macro program */
%ckparm;

/* Finally, invoke the STPBEGIN/STPEND macros with other code */
/* That uses the &type, &place and &mytitle macro vars */
%stpbegin;
*** other code to produce results that uses the macro variables;
%stpend;

[/pre]

However, if what you want to do is do some client-side validation BEFORE the stored process code is submitted, you would have to do that by coding your own front end (in whatever form -- HTML, Java, etc) and then invoking the stored process using the Stored Process Web Application. The Stored Process Web Application allows you to invoke a SAS Stored Process via URL.

It may be easier to make a parameter that is required such as: [pre]
Parm Desc Macro Var Name Possible Values
How To Run howrun Take All Defaults
Use My Selections
[/pre]

And then make sure that you specify defaults for all the other parameters. Then you can do any checking in your macro progerm instead of using the Stored Process Web Application and your own front end. If you need more help with using the SAS Macro Facility or SAS macro conditional logic, contact Tech Support.

If you want to learn more about the SPWA, you will find documentation here:
http://support.sas.com/rnd/itech/doc9/dev_guide/stprocess/stpwebapp.html

cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 184 views
  • 0 likes
  • 2 in conversation