# Reading in Packed Mainframe Data in SAS



## mbotoole (Oct 31, 2003)

I have a text file with data extracted from a mainframe. One of the fields contains dollar amounts with a format of *PIC S9(13)V99 COMP-3* per the file layout I have.

It should be have both negative and positive amounts, and i'm assuming 2 decimals, but i have no way of knowing. I've tried a variety of informats to read it in but i'm not sure if i'm using the right ones (zoned,packed,etc.) Any thoughts? Thanks.


----------



## Chicon (Jul 29, 2004)

Hi mbotoole,

The format of your value is specifical to COBOL. Normally, its size must be of 8 bytes on the mainframe.
If you want readable data, you should have a COBOL program which transfoms your file containing packed decimal data into a file containing edit data or readable data.

In your case, the program should contain for example :



> DATA DIVISION.
> FILE SECTION.
> .
> .
> ...


In my example, the amount will have the readable format *+9999999999999.99* or *-9999999999999.99* accordingly to its sign.


----------



## Chicon (Jul 29, 2004)

Also, if you have no way to make a COBOL translation program, I explain you how to read decimal packed data.

In your case, you have an amount of PIC S9(13)V99 COMP-3 format : this kind of COBOL format is only aimed for computation. In this case, the decimal point is ignored.
I told you in my prior post, this format takes 8 bytes on the mainframe.

Example 1 : you have an amount of + 12345.67, the 8 bytes will contain the following *HEXADECIMAL* values from left to right :

00 00 00 00 01 23 45 67 --> in decimal : 0 0 0 0 1 35 69 103

Example 2 : you have a negative amount of - 12345.67, this value will be stored this way :

*8*0 00 00 00 01 23 45 67 --> in decimal : *128* 0 0 0 1 35 69 103


----------

