Packed vs. Zoned Decimal: How to Handle Complex Binary Data in SAS External Files

This code is also available in: Deutsch Español Français
Difficulty Level
Intermediate
Published on :
Simon

Expert Advice

Simon
Expert SAS et fondateur.

External files are managed by the operating system, not SAS. While most modern data exchange happens via text (CSV, TXT), you may encounter efficient binary formats—often from mainframes or legacy systems—that require precise handling to read correctly.

Understand the structure of your external files to choose the right Informat.
This document explains the definitions of various types of external files and data formats used in SAS©. It covers:
  • binary data: numerical data stored in binary form in an external file. Binary numbers have a base of two and are represented by the digits 0 and 1.
  • binary column data storage: an older form of data storage that is no longer widely used and is not needed by most SAS© users. Binary column data storage compresses data so that more than 80 data elements can be stored. The advantage is that this method allows more data to be stored in the same space. Since map image datasets still exist, SAS© provides informats for reading binary column data.
  • external files: files managed and maintained by your operating system, not by SAS©. They contain data or text as input for SAS© tasks, or they are output files created as a result of SAS© tasks.
  • External files as input for a SAS© session: raw data records in external files that you want to read into SAS© as input, including data in the form of simple ASCII text files and binary files. Programming instructions in external files that you want to submit to SAS© for execution.
  • External files as output from a SAS© session: files where you want to store data or text, including data written as records in simple ASCII text files or data written in binary form. Files created as a result of running a SAS© program, including SAS© log files and the results of SAS© procedures. For example, the PRINTTO procedure allows you to direct procedure output to an external file. Each SAS© task creates at least one external file, the SAS© log. SAS© catalog files and ODS output destinations are also examples of external files.
  • packed decimal data: binary decimal numbers encoded 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 using an informat or format because there is no separate mantissa and exponent.
  • zoned decimal data: binary decimal numbers encoded such that each digit requires one byte of storage. The last byte contains the sign of the number as well as the last digit. Zoned decimal data produces a printable representation.
Data Analysis

Type : CREATION_INTERNE


Examples are not provided in this document, as this is a definitions page.

Pro Tip
Legacy Note: You can usually ignore "Binary Column Data" unless you are working with very old map files or compressed archives from the early days of computing.
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright © SAS Institute Inc. All Rights Reserved