Date: Thu, 19 Mar 2009 09:29:50 -0400
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: COBOL to sas layout error
Amy, Mikeee is right for sure, you should use COB2SAS.
This is a macro, which is not always able to convert all correctly, but
most (especially simple) COBOL structures are no problem.
Sometimes COB2SAS has a problem with REDEFINEd structure parts, but
normally the results are quite ok. Also some exotic constructs of types
might be a problem and that is not nice, because in that case the
following offsets might be wrong.
In your case I think the position of RRTSCID could be wrong? If the COBOL
structure (mybe you should post it here) is not interpreted correctly by
Insync, there might be a problem.
Eg if the cobol structure is something like:
10 xxxx PIC X(20)
10 yyyy PIC 9(4)
and the start position of xxxx is right (23), then the following field
starts at position 53, not 82. Be sure for numerics that you get the right
position... It's not always good to trust tools without having a look on
the "native" copybook-member.
If you are not sure, make the following:
use the COBOL data (which was written by that structure), use SAS to list
some typical records (sometimes there are different records, eg headers,
in the same structure, so don't list only one):
if _n_=10 then stop;
In log you get a list of 10 records with rulers and content in hex and
That you can compare to your COBOL structure and your INPUT statement. If
you find something like 414243 in hex as numeric, that might be ZD3.
(zoned -decimal), not IB. If you see it in hex, you can consult the
documentation for INFORMATs. There are examples of the hex-representation
for data for appropriate informats.
To be sure (I assume that you stay on mainframe and do not change
platform, eg reading mainframe data on PC?), you could use the S370 -
informats, like S370FZD11.2 That's all the same if you stay on mainframe,
but reads the S370 formats on other platforms. You need that if you are on
PC or UNIX to read mainframe data (I assume, your COBOL data ARE on
On Thu, 19 Mar 2009 08:49:52 -0400, Michael Raithel
>Amy posted the following:
>> Hello, Can anyone help me with this:
>> Insync browse shows the cobol layout as
>> LVL FIELD NAME FORMAT POS
>> 10 RHDR-ID C 20 23 00000000000012300
>> 10 RRTSCR-SCRD-ID B 4 87 286
>> so I code SAS as following.
>> @23 ID $20.
>> @87 RRTSCID IB4.
>> The data in ID field was read in correctly, RRTSCID was
>> wrong. I even tried RB4. still not work.
>Amy, I see that your posting has caught the attention of one of the 'L's
best and brightest--the Hashman; Paul D. While waiting for you to supply
him with additional information, I thought I would chime in with this
>If you are going to be doing a lot of SAS programming work that is taking
the place of existing COBOL programs, check out the COB2SAS program
written by the brainiacs at the SAS Institute. In their own words:
>"COB2SAS is a sample program provided by SAS Institute Inc. as a tool
that can assist you in converting COBOL language data description entries
into equivalent SAS language statements."
>There are instructions for downloading and installing it here:
http://support.sas.com/techsup/technote/ts536.html , and I note that it
was just updated on 2/26/2009, so it appears to be pretty fresh.
>Amy, best of luck getting COBOL-created files into your SAS programs!
>I hope that this suggestion proves helpful now, and in the future!
>Of course, all of these opinions and insights are my own, and do not
reflect those of my organization or my associates. All SAS code and/or
methodologies specified in this posting are for illustrative purposes only
and no warranty is stated or implied as to their accuracy or
applicability. People deciding to use information in this posting do so at
their own risk.
>Michael A. Raithel
>"The man who wrote the book on performance"
>Author: Tuning SAS Applications in the MVS Environment
>Author: Tuning SAS Applications in the OS/390 and z/OS Environments,
>Author: The Complete Guide to SAS Indexes
>The end of the human race will be that it will eventually die of
civilization. - Ralph Waldo Emerson