• Print  |
  • Feedback  |

Knowledge Base


TS-620

  • What does COB2SAS do?

COB2SAS is a tool that can be used to convert a COBOL FILE DESCRIPTOR SECTION into a SAS INPUT and LABEL statement. It reads as it's input your COBOL COPYBOOK. It produces a SAS INPUT statement and a SAS LABEL statement. The LABEL statement associates the 32 character data names with the 8 character SAS variable names. It also produces a SAS data library that contains all of the information that it gathered about the copybook.

  • What is the most current release of COB2SAS?

The most current release is Release 2, which was made available in July of 1990; however, there has been one fix to COB2SAS since then. The fix is in the R2COB2 file. The new R2COB2 file is incorporated into the zipped COB2SAS downloadable file on the SAS ftp site and on the SAS Web site. If you want only the changed R2COB2 member, then you can download it from ftp://ftp.sas.com/techsup/download/mvs/cob2sas/. For more information about Release 2 of COB2SAS see the Release Notes.

There is also a V8 modified version of COB2SAS that adds support for long variable names and other enhancements.

  • How do I get COB2SAS?

It's available in downloadable form on the SAS web site. In order to install it, you will need installation instructions. These can be obtained in Technical Support Document TS-536. This document contains links to the download locations. If you don't have the capability to download files from the web, you can have a copy mailed to you by contacting the SAS Technical Support Department at 919-677-8008.

  • Is there any documentation for COB2SAS?

Yes! The documentation is online. COB2SAS comes with a number of files. Five of the files contain documentation. The following are a list of the files and the documentation they contain:

    • R2USGD - Usage Guide
    • R2RFRN - Reference Guide
    • R2RNTS - Release Notes
    • R2NSTL - Install Guide
    • DSCLMR - Disclaimer
  • Will COB2SAS run on any platforms other than MVS, CMS, VMS, and VSE?

COB2SAS is designed to work on MVS, CMS, VMS, and VSE. Since COB2SAS is just a big data step, it will physically execute on any platform that SAS runs on with minor modifications to the COB2SAS code. The problem is that it is very likely that either COB2SAS will not be able to parse the copybook or that the INPUT statement COB2SAS generates will not work on other platforms because of differences in the way that packed fields are stored.

In order for COB2SAS to work on another platform, a few things must be true. First the COBOL syntax of the copybook your trying to convert has to conform to ANSI specification X3.23-1985. Second, the various pictures clauses and usages must translate to the SAS informats in the way that is described in SAS Note
V6-SYS.SYS-2503

If these two things are true, then it should work; however, you must keep in mind that Technical Support will only address issues on the MVS, CMS, VMS, and VSE platforms.

The V8 modified version of COB2SAS already has the required code changes to run COB2SAS on PC and Unix platforms.

  • Why am I only getting the LABEL statement in my OUTSAS DD when I run COB2SAS against my copybook?

If your OUTSAS DD is not being allocated DISP=MOD, you will see this behavior. You will also see this behavior when the OUTSAS DD points to a PDS member. Partition Data Sets to not support DISP=MOD.

The reason the OUTSAS has to be allocated DISP=MOD is because the INPUT statement is written to the OUTSAS DD in one data step (contained in the R2COB6 member). The LABEL statement is then written in another data step (contained in the R2COB7 member). When the OUTSAS DD is allocated DISP=OLD, the data step which writes the LABEL statement overwrites the contents of OUTSAS, and you only get the LABEL statement. When OUTSAS is allocated DISP=MOD, the LABEL statement is appended after the INPUT statement.

The V8 modified version of COB2SAS has corrected this problem by writing both the INPUT and LABEL statements in 1 data step.

  • Why isn't COB2SAS expanding my OCCURS clauses?

By default COB2SAS doesn't expand OCCURS clauses. If you want COB2SAS to expand OCCURS clauses, you must edit your R2MVS, R2CMS, R2VMS, or R2VSE member (depending on which operating system you are using). Locate the line of code that includes the R2COB5 program. By default this line is commented out. Uncomment the line, save the program, and COB2SAS will expand your OCCURS clauses.

Note that COB2SAS will not expand nested OCCURS clauses. COB2SAS will also assume the upper bound when it encounters an OCCURS DEPENDING ON clause.

In the V8 modified version of COB2SAS, the default is to expand OCCURS clauses

  • Why am I getting 'INVALID DATA' messages when using the INPUT statement that COB2SAS generated?

This could be happening for any of the following reasons:

    • The column positioning in the INPUT statement may not be correct. This frequently happens when COB2SAS encounters something in the copybook that it is unable to handle. See the next FAQ for a list of things that COB2SAS can not handle. Locate the offending statement in your copybook. If it is possible, you may be able to use a COBOL comment in your copybook to comment out the statements that COB2SAS can't handle, then rerun COB2SAS. COB2SAS ignores lines in your copybook that are commented out. If it is not possible to comment the offending code, then you'll have to manually translate your copybook.
    • Your column positioning in the INPUT statement may be off because COB2SAS did not expand the OCCURS clauses if you have one in your copybook. See the previous FAQ for information about this situation.
    • Your column positioning in the INPUT statement may be off if your copybook contained an OCCURS DEPENDING ON clause. COB2SAS always assumes the upper bound when it encounters this clause. If this is he case, you'll have to code logic to read in the DEPENDING ON variable, leave a trailing @ in the INPUT statement, then set up a DO loop (using the DEPENDING ON variable as the do loop upper bound) reading in each occurrence.
    • HIGH-VALUES or LOW-VALUES may be in your copybook. SAS doesn't have the concept of low or high values. This should be easy to detect by looking in the hex dump in your SASLOG of the record being read. If you do have high or low values in your data, one approach would be to read the field in as character and test for '00'x and 'FF'x. If it's not, then use the INPUT function to convert it to the appropriate numeric. Another approach would be to use the ? ? modifier on your INPUT statement so that the 'INVALID DATA' messages aren't generated.
  • What are the things that COB2SAS can not handle?
    • Nested REDEFINES groups. This is one of the caveats documented in the Usage Guide. If your copybook contains one, the only way around it is to comment out the innermost redefines clause. If that's not possible, you'll just have to manually translate the copybook.
    • Nested OCCURS clauses. This is also one of the caveats documented in the Usage Guide. Unfortunately, there is no circumvention for this situation. You will have to manually translate the copybook.
    • Group variables within a redefined block. When COB2SAS encounters one of these, it thinks it has encountered the end of the group. The column positioning from that point on will be incorrect. Since COB2SAS ignores group variables anyway, you can comment out the group variable to circumvent.
    • Data names that start with a numeric. When COB2SAS encounters one of these, it thinks that another level has been encountered. Everything from that point on will be incorrect. To circumvent, insert a character before the variable name so that it no longer begins with a numeric.
    • VALUE clauses that extent into multiple lines. COB2SAS ignores VALUE clauses anyway. To circumvent, either comment out or delete the VALUE clause.
    • The use of '.' for the decimal place in a picture clause instead of the V. To COB2SAS, a '.' means the sentence has ended. When you use one in a picture clause, it causes problems. To circumvent, replace the '.' with a V in your picture clause.
  • How do I route the INPUT and LABEL statements to a flat file?

First you must edit your R2MVS, R2CMS, R2VMS, or R2VSE member (depending on which operating system that you are on). Locate the commented line of code that says:

%LET FILE = FILE OUTSAS;

Uncomment this line. You then must allocate a fileref called OUTSAS. If you are on MVS, make sure that you allocate it with DISP=MOD! The method for doing this is documented in the 'Redirecting Output under XXX' (where XXX is your operating system). For further information, refer to that document.

This change is already made in the V8 modified version of COB2SAS.

  • Why am I getting the following error when I run COB2SAS:

ERROR: The POINT= data set option is not valid for the data set WORK.DICTNRY, the data set must be accessible by observation number for POINT= processing.

You're getting this error because you have the COMPRESS=YES system option set. COB2SAS uses the SET statement with the POINT= option. You can not use POINT= on a compressed data set. To circumvent specify COMPRESS=NO.

  • Why aren't the variables in my INPUT statement in the same order as they appear in the copybook?

COB2SAS sorts the variables by the ATBYTE position. If this is not the desired behavior, then you can comment out the PROC SORT statement at the bottom of your R2COB5 program. Deleting this PROC SORT will cause the order to match that of the copybook.

  • Why am I not getting the filler variables or group variables in the INPUT statement?

Fillers are just that - fillers. Your COBOL program isn't using them, so COB2SAS ignores them. SAS doesn't have the group variable construct so COB2SAS ignores them too.