You can use the Transformation Generator wizard to create a custom
transformation that reads input in the form of an XML table, process
the input, and then write output in the form of an XML table. For
an introduction to the Transformation Generator wizard, see
Creating and Using a Generated Transformation.
In the sample job, we need a custom transformation that reads values for temperature
and scale, in
the format specified by InTemp.xml. The transformation converts the temperature in
one scale to the equivalent temperature in the other scale, and then writes the result
in the format specified by OutTemp.xml.
Perform the following steps or similar steps to create a custom transformation for
a job that can be deployed as a Web service:
-
Right-click the destination
folder in the Folders tree where the new transformation should be
stored. Then select
NewTransformation. The first page of the
Transformation Generator wizard displays.
-
Enter a name for the transformation. In the sample job, the transformation is named
Convert Temp GT.
-
Review other values
on this page and make changes as desired, and then click
Next. The SAS Code page displays.
-
Add SAS code that reads input in the form of an XML table, process the input, and
then write output in the form of an XML table. In the sample job, the following SAS
code is added to this page.
data &_OUTPUT;
set &_INPUT;
keep CalculatedTemperature;
length NewTemperature 8.;
if (Unit="F") then
do;
NewTemperature=(5/9)*(Temperature-32);
Unit="C";
CalculatedTemperature = "Temperature of " || compress(temperature) ||
" degrees Farenheit = " || compress(NewTemperature) ||
" degrees Centigrade" ;
end;
else if (Unit="C") then
do;
NewTemperature=(9/5)*(Temperature)+32;
Unit="F";
CalculatedTemperature = "Temperature of " || compress(temperature) ||
" degrees Centigrade = " || compress(NewTemperature) ||
" degrees Farenheit" ;
end;
else
do;
CalculatedTemperature="Temperature of " || compress(temperature) ||
" with unit of " || compress(unit) || " cannot be converted ";
Unit="";
end;
run;
-
When you are satisfied
with the code, click
Next . The Options page displays. Specify options as desired. The sample job does not
require any options. When ready, click
Next. The
Transform properties page displays.
-
Specify transformation properties as desired. For the sample job, the following properties
are specified:
Transform
supports inputs (selected)
Maximum
number of inputs (1)
Transform
supports outputs (selected)
Maximum
number of outputs (1)
Automatically
generate delete code for outputs (deselected)
Note: Be sure to deselect the Automatically generate delete code for outputs property.
It is not appropriate for Web service jobs.
-
Click
Finish to save the transformation. In the Folders tree, the custom transformation
appears in the folder that you right-clicked in step 1. In the Transformations
tree, the custom transformation appears in the
Ungrouped folder or another category that you specified in step 3.