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. Alternatively, you can use a file URL if it is local to the middle tier server( for example, file:////temp/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 local because they are associated with the task:
simple workflow showing one task
Data Object Label
Type
Value
Total
Short Text
0
Total Category
Short Text
sales
Next, associate the policy definition with the task.
Policy Property
Value
Name
Task Started->Invoke SAS Code
Description
This policy sends the var parameter value to the hosted SAS code example and assigns the result to the Total data object.
Event
Task Started
Action
Invoke SAS Code
SAS Source Code
http://host-name/invokeSASCodeTutorial.sas
Server
SASApp – Logical Workspace Server
Repository
Foundation
Pass all root workflow data objects
disabled
(Output) Data Object
InvokeSASCode Tutorial/Tutorial Task/Total
(Input 1) Data Object
InvokeSASCode Tutorial/Tutorial Task/Total Category
(Input 1) Macro Variable
var
(Output) Macro Variable
result
See Invoke SAS Code for more information.
The final workflow definition is as follows:
workflow diagram and workflow tree for workflow with one task
Multiple data objects can be passed to the SAS code via corresponding input macro variables. Because this example requires only one input variable, the following line of code is prepended to the SAS code before execution:
%let var=sales;
Only a single return variable is supported. See the examples provided with SAS Workflow Studio for details of this example.
Last updated: March 5, 2020