Previous Page | Next Page

Informats

PDw.d Informat



Reads data that are stored in IBM packed decimal format.
Category: Numeric
See: PBw.d Informat under Windows UNIX OpenVMS z/OS

Syntax
Syntax Description
Details
Comparisons
Examples
Example 1: Reading Packed Decimal Data
Example 2: Creating a SAS Date with Packed Decimal Data

Syntax

PDw.d

Syntax Description

w

specifies the width of the input field.

Default: 1
Range: 1-16
d

specifies the power of 10 by which to divide the value. This argument is optional.

Range: 0-10

Details

The PDw.d informat is useful because many programs write data in packed decimal format for storage efficiency, fitting two digits into each byte and using only a half byte for a sign.

Note:   Different operating environments store packed decimal values in different ways. However, PDw.d reads packed decimal values with consistent results if the values are created on the same type of operating environment that you use to run SAS.  [cautionend]

The PDw.d format writes missing numerical data as -0. When the PDw.d informat reads -0, it stores it as 0.


Comparisons

The following table compares packed decimal notation in several programming languages:

Language Notation
SAS PD4.
COBOL COMP-3 PIC S9(7)
IBM 370 Assembler PL4
PL/I FIXED DEC


Examples


Example 1: Reading Packed Decimal Data

input @1 x pd4.; 

Data Line* Results
----+----1

0000128C
128
* The data line is a hexadecimal representation of a binary number stored in packed decimal form. Each byte occupies one column of the input field.


Example 2: Creating a SAS Date with Packed Decimal Data

input mnth pd4.; 
date=input(put(mnth,6.),mmddyy6.);

Data Line* Results
----+----1

0122599C
14603
* The data line is a hexadecimal representation of a binary number that is stored in packed decimal form on an IBM mainframe operating environment. Each byte occupies one column of the input field. The result is a SAS date value that corresponds to December 25, 1999.

Previous Page | Next Page | Top of Page