In
accordance with traditional TRANSPOSE behavior, when no VAR statement
is specified, the analysis variables participating in the transposition
are those that are numeric in the Base SAS context. To involve other
variables in the transposition, explicitly specify them in a VAR statement.
The Base SAS language
has two types of variables: numeric and character. Database management
and file systems, on the other hand, have many different variable
data types. When the TRANSPOSE procedure is run inside the database
or file system, the SAS In-Database Code Accelerator is the interface
between the two systems. The SAS In-Database Code Accelerator supports
more data types than traditional Base SAS but likely fewer than the
number of data types that are supported by the database or file system.
When running within the SAS Embedded Process, DS2 converts and preserves
data types as best it can. When processed inside the database, the
TRANSPOSE procedure runs DS2 programs within the SAS Embedded Process.
The DS2 programs uses neither the SAS variable types nor the database
or file system data types. It uses DS2 data types.
The work of the TRANSPOSE
procedure, introduces an additional difficulty. The difficulty is
the determination of a data type for output variables that can preserve
the values of the input variables. A common data type must be determined
for all output variables to hold the transposed results of the input
variables. If all input analysis variables (those listed in the VAR
statement or implied by the lack of one) are of the same data type,
then the data type of all result variables in the output is exactly
the same as the input data type.
For example, if all
input variables to be transposed are of the double-precision, floating-point
data type, then all result variables in the output are double-precision,
floating-point. However, if the input analysis variables are not of
the same type, then a common type capable of preserving the values
of all input variables must be determined. For example, similar to
traditional TRANSPOSE operation, if there are two input analysis variables,
and one is double-precision, floating-point while the other variable
is character, then all result output variables must be of the character
type. Using DS2 in the SAS Embedded Process complicates this common
type determination because DS2 supports more than just the two traditional
SAS variable types. For in-database processing, the TRANSPOSE procedure
first attempts to preserve the data type of the input analysis variables
in the output. If that is not possible, the TRANSPOSE procedure attempts
to determine a common representative type that allows the full precision
of input values to be preserved in the output. For numeric data types,
if no common output type can preserve full numerical precision, then
the TRANSPOSE procedure uses the approximate double-precision, floating-point
data type to ensure that the magnitude and range of values are preserved.