SAS code (keywords
and data) are submitted for execution as text. During parsing, numeric
data is converted to the floating-point representation that is used
by the operating environment and computer. For UNIX and Windows, numeric
data is represented in IEEE floating-point format. For
z/OS, numeric
data is represented in IBM floating-point format.
When using
SAS/CONNECT and Remote Library Services to
process numeric data in a cross-architecture client/server session,
you might get unexpected, but logical, results.
Consider a scenario
in which a
SAS/CONNECT client
session under Windows accesses a server session under
z/OS. In this
code example, the value -6.14, which is stored in a data set, is used
in a WHERE clause. This number cannot be represented exactly in either
IEEE or IBM floating-point formats because -6.14 is a repeating decimal,
in binary. Regardless of whether -6.14 is stored under Windows or
z/OS, its representation is imprecise.
/* Start a server session on z/OS */
options comamid=tcp remote=zos;
filename rlink "c:\sas\v9\connect\saslink\tcptso.scr";
signon;
/* The following code is remotely submitted to the server session */
/* under z/OS. The text is passed to z/OS and is parsed on z/OS. */
/* When the text "-6.14" is parsed on z/OS, the resulting value */
/* is stored on z/OS in IBM floating-point format. */
rsubmit;1
data sasuser.test_4;
format RUE_H comma18.2;
RUE_H= –6.14; output;
RUE_H= –6.14; output;
RUE_H= –6.14; output;
RUE_H= –6.14; output;
run;
endrsubmit;
/* The following code assigns a server library on z/OS. */
libname test1 server=sdczos slibref=sasuser;
/* The following statements are parsed in the client session */
/* on Windows, and the results are stored in IEEE format. */
/* in the client session in IEEE format. */
/* You might expect the following WHERE clause to return zero */
/* records because the expression resolves to 0. */
/* However, this code execution returns 4. */
proc sql;2
create table xx2 as
select RUH_H
from test1.test_4
where RUE_H < -6.14 3;
quit;
1Parsing the string "-6.14" on z/OS produces a binary IBM representation
of -6.14.
2Parsing the string "-6.14" on Windows produces a binary IEEE representation
of -6.14.
3The WHERE clause, which contains the Windows binary IEEE value, is
sent to z/OS via RLS, the IEEE representation of -6.14 is converted
to its closest binary IBM equivalent. However, when an IEEE binary
representation of -6.14 is converted into IBM format, the result is
different from the IBM binary value that was obtained by parsing and
converting the string on z/OS.
The clause
where RUE_H < -6.14
finds four observations because
the binary IBM value that is obtained by converting the binary IEEE
value is slightly smaller than the binary IBM value that was stored
in the data set when "-6.14" was originally parsed. Although you might
expect the WHERE clause to return no observations, it returns four
observations because of the lack of precision that occurs when converting
data across operating environments.
To avoid cross-architecture
problems, you could change the code so that PROC SQL is remotely submitted
to execute in the server session on
z/OS. The text value, "-6.14",
in the WHERE clause would be parsed and converted on
z/OS and would
result in the same binary representation that was used in the original
data set, which was also parsed and converted in the server session
on
z/OS. Therefore, the WHERE clause would return no observations,
as expected.
rsubmit;
proc sql;
create table xx2 as
select RUH_H
from test1.test_4
where RUE_H < -6.14 ;
quit;
endrsubmit;
When using
SAS/CONNECT and RLS to process floating-point
numbers in a cross-architecture environment, ensure that all statements
are parsed in the same session, either the client or the server.