Invoke SAS Code Policy Example

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:
shoeSales
is the name of the column in the shoes data set.
var
is a macro variable whose value is passed to the SAS code from a source workflow data object.
result
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:
simple process showing one activity
Data Object Label
Type
Value
Total
Short Text
0
Total Category
Short Text
sales
Next, associate the policy definition with the activity.
Policy Parameter
Value
Event
Process Started
Action
Invoke SAS Code
Description
Source URI
http://localhost/InvokeSASCodeTutorial.sas
Logical Server Name
SASApp – Logical Workspace Server
Repository Name
Foundation
Result Macro Variable
result
Return Data Object
InvokeSASCode Tutorial/Tutorial Activity/Total
Pass all root process data objects
disabled
Parameter 1 Data Object
InvokeSASCode Tutorial/Tutorial Activity/Total Category
Parameter 1 Macro Variable
var
Policy Label
Process SAS Code->Invoke SAS Code
The parameters for this policy example include the following:
Source URI
is the location of the SAS code as served by the Web application server.
Logical Server Name
is the name of the Logical Workspace Server that executes the SAS code.
Repository Name
is the name of the metadata repository in which the specified logical server is defined.
Result Macro Variable
is the macro variable (result) in the SAS code that contains the value that is returned to the workflow in the specified data object.
Return Data Object
is the workflow data object (Total) that holds the value from the Result Macro Variable.
Parameter 1 Data Object
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:
process diagram and process tree for process with one activity
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.