Spotfire data inputs and outputs for SAS
The only part of the SAS software required by Spotfire Statistics Services is Base SAS. Other SAS software packages are not required, but they can be installed on the machine.
For general information regarding scripting using SAS scripts, refer to your SAS software documentation.
An input to a Spotfire data function can have a type of Table (a whole data set), Column (a single column), or Value (a single scalar). A Table or Column input are accessible in a SAS script as a SAS data set with the name given by the data function input variable.
After the script is executed, the data function outputs are retrieved from SAS data sets with the names of the output variables. If one of these data sets is not found (because the script did not create it), an error is generated. If Spotfire expects an output to contain a column or a scalar value, it generates an error if the actual data has multiple columns (for a column output) or multiple rows and columns (for a scalar value output).
The following is a SAS script that takes an input data table named myinput, adds two new columns (rnum and cnum), and produces an output data set named myoutput:
DATA myoutput;
SET myinput;
rnum = UNIFORM(-1);
cnum = 10*_N_;
RUN;
A Value data function input is interpreted differently than a Table or Column input. Rather than using the single scalar value to create a SAS data set, it is used to define a SAS macro variable whose name is the data function input variable, and whose value is the character string produced from the Spotfire scalar value. Using macro variables is a common way to parameterize SAS scripts, which matches the purpose of Spotfire Value inputs.
For example, if you define a Value input named
filename
, and its value is the string
D:/temp.txt, then the following macro variable definition is added to the beginning of the SAS script:
%LET filename D:/temp.txt;
This macro variable can be referenced within the SAS script using SAS code such as the following, which reads from the specified text file, producing the output data set filedata.
DATA filedata;
INFILE '&filename';
INPUT A $ B $ Num;
RUN;