LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 1996, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 20 Sep 1996 00:53:26 GMT
Reply-To:     Francois Hebert <frheber@IBM.NET>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Francois Hebert <frheber@IBM.NET>
Organization: F-G-L-M
Subject:      Re: Reading Cobol packed decimal data

John E. Bentley <bentleyj@ix.netcom.com> wrote in article <51mn1t$dru@dfw-ixnews5.ix.netcom.com>... > I have a VSAM file that contains packed decimal numeric data. How > does one convert the 'picture' from the data dictionary and record > layout to a SAS informat. Can someone provide guidlines or a tabular > reference? > > The SAS Language manual page 656 shows that COMP-3 PIC S9(7) can be > read using PD4. But I have a variable with PIC S9(2) V9(5). How do I > read that? And what about PIC S9(3) and PIC S9(7) v99? > > Nobody here really understands VSAM and COBOL. We have some legacy > applications that run and nobody worries about them. Now I've got a > new dataset and don't know what to do with it. > > Thanks in advance. > >

> Frangois Hibert < > > First, you must evaluate the total number of bytes for the field. This is given by the formula: Number of bytes = integer(Number_of_digits / 2) + 1 1 - Evaluate the number of bytes: PIC S9(x)V9(y) COMP-3 ====> x + y digits

2 - Evaluate of the number of bytes: PIC S9(2)V9(5) COMP-3 = integer( (2+5) / 2) + 1 = integer(7 / 2) + 1 = 3 + 1 = 4 bytes PIC S9(3) COMP-3 = integer(3/2) + 1 = 2 bytes PIC S9(7)V99 COMP-3 = integer(9/2) + 1 = 5 bytes

3 - Evaluate the SAS format The number of bytes gives you the length of your SAS format (e.g. PD4._ PD2._ ...)

The number of decimals is given by the cobol format (the V__ part).

Having the number of bytes, you can define your SAS format like this:

PIC S9(2)V9(5) COMP-3 takes 4 bytes (with 5 decimals) ===> In SAS, PD4.5 PIC S9(3) COMP-3 takes 2 bytes (with 0 decimals) ===> In SAS, PD2.0 PIC S9(7)V99 COMP-3 takes 5 bytes (with 2 decimals) ===> In SAS, PD5.2

This should do the job..... Good luck!


Back to: Top of message | Previous page | Main SAS-L page