Date: Wed, 8 Oct 1997 12:24:48 PDT
Reply-To: Melvin Klassen <KLASSEN@UVVM.UVIC.CA>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Melvin Klassen <KLASSEN@UVVM.UVIC.CA>
Subject: Re: Packed Decimals
Michael Cadavillo <MCadavillo@HEALTHFIRST.ORG> writes:
>
> I have a file that needs to read into SAS.
> I included 3 records, and displayed only the fields I'm interested in.
> I also included part of the program to read the file.
>
> The file looks as follow:
> --------------------------------
> @20 @144 @154
>
> 970714 000000571G000000000{
> 970714 000001533D000000000{
> 970714 000001843E000000000{
This looks fine, if you use the 'ZDw.d' informat,
i.e., the first nine bytes are in the range of '0' to '9'
and the last byte is in "overpunch" format, namely
'G' --> EBCDIC X'C7' ('7' overpunched with '+' sign)
or 'D' --> EBCDIC X'C4' ('4' overpunched with '+' sign)
or 'E' --> EBCDIC X'C5' ('5' overpunched with '+' sign)
or '{' --> EBCDIC X'C0' ('0' overpunched with '+' sign)
or 'J' --> EBCDIC X'D1' ('1' overpunched with '-' sign)
or 'R' --> EBCDIC X'D9' ('9' overpunched with '-' sign)
i.e., multiply the ten digits by plus-one or minus-one,
depending on the "overpunched" sign, to get the final result.
> The program looks as follows:
> filename inf1 'r:\spool\remit.txt' lrecl=340 recfm=f;
> data inuse;
> infile inf1 truncover;
> input
> @20 remdatx $ebcdic6.
> @144 bilamt s370fpd10.2
> @154 remamt s370fpd10.2;
The 'PD' informat squeezes two numeric digits into each byte,
except for the final byte, i.e., you could read '12345D'X
using a 'PD3.0' informat, to get '-12345'. Your data is *NOT* in this format.
> The problem I have, is I do not know how I can read the packed decimal
> BILAMT and REMAMT without getting any errors. How do I correctly
> read the BILAMT and REMAMT? According to the file layout, the BILAMT is in
> COBOL PIC 9(08) V99 format and the REMAMT is in COBOL PIC S9(08)V99 format.
Note that the "eight-occurrences-of-9-VEE-99" definition states
that there is an implied decimal between the eighth and ninth characters,
i.e., the value represents "dollars-and-cents", not just "dollars".