Reading Binary Data


Definitions

binary data

  • is numeric data that is stored in binary form. Binary numbers have a base of two and are represented with the digits 0 and 1.

packed decimal data

  • are binary decimal numbers that are encoded by using each byte to represent two decimal digits. Packed decimal representation stores decimal data with exact precision; the fractional part of the number must be determined by using an informat or format because there is no separate mantissa and exponent.

zoned decimal data

  • are binary decimal numbers that are encoded so that each digit requires one byte of storage. The last byte contains the number's sign as well as the last digit. Zoned decimal data produces a printable representation.

Using Binary Informats

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 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.

Different computer platforms store numeric binary data in different forms. The ordering of bytes differs by platforms that are referred to as either 'big endian' or 'little endian.' For more information, see 'Byte Ordering for Integer Binary Data on Big Endian and Little Endian Platforms' on page 32.

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.

Table 21.4: Informats for Native or IBM 370 Mode

Description

Native Mode Informats

IBM 370 Mode Informats

ASCII Character

$ w.

$ASCII w.

ASCII Numeric

w.d

$ASCII w.

EBCDIC Character

$ w.

$EBCDIC w.

EBCDIC Numeric (Standard)

w.d

S370FF w.d

Integer Binary

IB w.d

S370FIB w.d

Positive Integer Binary

PIB w.d

S370FPIB w.d

Real Binary

RB w.d

S370FRB w.d

Unsigned Integer Binary

PIB w.d

S370FIBU w.d ,

S370FPIB w.d

Packed Decimal

PD w.d

S370FPD w.d

Unsigned Packed Decimal

PK w.d

S370FPDU w.d or PK w.d

Zoned Decimal

ZD w.d

S370FZD w.d

Zoned Decimal Leading Sign

S370FZDL w.d

S370FZDL w.d

Zoned Decimal Separate Leading Sign

S370FZDS w.d

S370FZDS w.d

Zoned Decimal Separate Trailing Sign

S370FZDT w.d

S370FZDT w.d

Unsigned Zoned Decimal

ZD w.d

S370FZDU w.d

If you write a SAS program that reads binary data and that will be 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.

For complete descriptions of all SAS formats and informats, including how numeric binary data is written, see SAS Language Reference: Dictionary .

[*] For example, using the IBM 370 informats, you could download data that containbinary integers from a mainframe to a PC and then use the S370FIB informats to read the data.




SAS 9.1 Language Reference. Concepts
SAS 9.1 Language Reference Concepts
ISBN: 1590471989
EAN: 2147483647
Year: 2004
Pages: 255

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net