SAS can read binary data with the special instructions
supplied by SAS informats. You can use formatted input and specify
the informat in the INPUT statement. The informat that you choose
is determined by the following factors:
-
the type of number being read:
binary, packed decimal, zoned decimal, or a variation of one of these
-
the type of system on which the
data was created
-
the type of system that you use
to read the data.
SAS provides a number of
informats for reading binary data and corresponding formats for writing
binary data. Some of these informats read data in native mode, that
is, by using the byte-ordering system that is standard for the system
on which SAS is running. Other informats force the data to be read
by the IBM 370 standard, regardless of the native mode of the system
on which SAS is running. The informats that read in native or IBM
370 mode are listed in the following table.
Informats for Native or IBM 370 Mode
|
|
|
|
|
|
|
|
|
|
|
|
EBCDIC Numeric (Standard)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Zoned Decimal Leading
Sign
|
|
|
Zoned Decimal Separate
Leading Sign
|
|
|
Zoned Decimal Separate
Trailing Sign
|
|
|
|
|
|
If you write a SAS program
that reads binary data and that is run on only one type of system,
you can use the native mode informats and formats. However, if you
want to write SAS programs that can be run on multiple systems that
use different byte-storage systems, use the IBM 370 informats. The
IBM 370 informats enable you to write SAS programs that can read data
in this format and that can be run in any SAS environment, regardless
of the standard for storing numeric data. The IBM 370 informats can also be used to read data
originally written with the corresponding native mode formats on an
IBM mainframe.
Note: Any time a text file originates
from anywhere other than the local encoding environment, it might
be necessary to specify the ENCODING= option on either EBCDIC or ASCII
systems. When you read an EBCDIC text file on an ASCII platform, it
is recommended that you specify the ENCODING= option in the FILENAME
or INFILE statement. However, if you use the DSD and the DLM= or DLMSTR=
options on the FILENAME or INFILE statement, the ENCODING= option
is a requirement because these options require certain characters
in the session encoding (such as quotation marks, commas, and blanks).
The use of encoding-specific informats should be reserved for use
with true binary files that contain both character and non-character
fields.