Writing Binary Data


IBM mainframes, Hewlett Packard 9000, and most other UNIX systems store bytes in one order, called big-endian. Intel-based, or IBM compatible microcomputers and the VAX and Alpha computers manufactured by Compaq store bytes in a different order called byte- reversed , or little-endian.

Binary data stored in one order cannot be read by a computer that stores binary data in the other order without additional processing taking place. When you are designing SAS applications, try to anticipate how your data will be read and choose your formats and informats accordingly .

SAS provides two sets of informats for reading binary data and corresponding formats for writing binary data.

  • The IB w . d , PD w . d , PIB w . d , and RB w . d informats and formats read and write in native mode, that is, using the byte-ordering system that is standard for the machine.

  • The S370FIB w . d , S370FPD w . d , S370FRB w . d , and S370FPIB w . d informats and formats read and write according to the IBM 370 standard, regardless of the native mode of the machine. These informats and formats allow you to write SAS programs that can be run in any SAS environment, regardless of how numeric data are stored.

If a SAS program that reads and writes binary data runs on only one type of machine, you can use the native mode informats and formats. However, if you want to write SAS programs that can be run on multiple machines using different byte-storage systems, use the IBM 370 formats and informats. The purpose of the IBM 370 informats and formats is to enable you to write SAS programs that can be run in any SAS environment, no matter what standard you use for storing numeric data.

For example, suppose you have a program that writes data with the PIB w . d format. You execute the program on a microcomputer so that the data are stored in byte-reversed mode. Then on the microcomputer you run another SAS program that uses the PIB w . d informat to read the data. The data are read correctly because both of the programs are run on the microcomputer using byte-reversed mode. However, you cannot upload the data to a Hewlett Packard 9000-series machine and read the data correctly because they are stored in a form native to the microcomputer but foreign to the Hewlett Packard 9000. To avoid this problem, use the S370FPIB w . d format to write the data; even on the microcomputer, this causes the data to be stored in IBM 370 mode. Then read the data using the S370FPIB w . d informat. Regardless of what type of machine you use when reading the data, they are read correctly.




SAS 9.1 Companion for Windows
SAS 9.1 Companion for Windows (2 Volumes)
ISBN: 1590472004
EAN: 2147483647
Year: 2004
Pages: 187

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