This example demonstrates
the use of data objects passed as macro variables used in the following
simple SAS program:
data shoeSales;
set sashelp.shoes end=final;
retain total 0;
total = total + &var;
if final then call symputx('result', total);
run;
This example defines
the following variables:
is the name of the
column in the shoes data set.
is a macro variable
whose value is passed to the SAS code from a source workflow data
object.
is the macro variable
that holds the return value used to populate the target workflow data
object.
If this code is hosted
by a Web application server and the file is named invokeSASCodeTutorial.sas,
then the file is accessible at
http://host-name/invokeSASCodeTutorial.sas
.
Note: Versions 7.0 and higher of
Microsoft Internet Information Services do not handle unrecognized
file types, so a MIME type must be added for the .sas file extension.
First, define the relevant
workflow and data objects. In the following example, the data objects
are associated with the activity and are visible in the entire subtree:
Next, associate the
policy definition with the activity.
|
|
|
|
|
|
|
|
http://localhost/InvokeSASCodeTutorial.sas
|
|
SASApp – Logical
Workspace Server
|
|
|
|
|
|
InvokeSASCode Tutorial/Tutorial
Activity/Total
|
Pass all root process
data objects
|
|
|
InvokeSASCode Tutorial/Tutorial
Activity/Total Category
|
Parameter 1 Macro Variable
|
|
|
Process SAS Code -> Invoke SAS Code
|
The parameters for this
policy example include the following:
is the location of
the SAS code as served by the Web application server.
is the name of the
Logical Workspace Server that executes the SAS code.
is the name of the
metadata repository in which the specified logical server is defined.
is the macro variable
(result) in the SAS code that contains the value that is returned
to the workflow in the specified data object.
is the workflow data
object (Total) that holds the value from the Result Macro Variable.
is the workflow data
object (Total Category) whose value is passed to the SAS code in the
macro variable specified by Parameter 1 Macro Variable (var).
The final workflow definition
is as follows:
Up to five data objects
can be passed to the SAS code via corresponding macro variables. Because
this example only requires one, the following line of code is prepended
to the SAS code prior to execution:
%let var=sales;
See the examples provided
with SAS Workflow Studio for details of this example.