SAS® informats that correspond to COBOL data descriptions


The COBOL programming language uses a picture clause for data description. The COBOL PICTURE and USAGE are used to determine the data type and the corresponding SAS informat. Pictures using an "X" represent character values. Pictures using a "9" represent numeric values, which might also contain an "S" to indicate that the value is signed and a "V" to show the location of an implied decimal point. Pictures using a "9" that also contain a USAGE or an "S" (signed) indicate the non-standard numeric type of the value. The term "non-standard numeric" refers to numeric values such as packed decimal, zoned decimal, real binary, and integer binary.

The COBOL PICTURE describes the actual (resulting) width of the value by the number of Xs or 9s in the picture or by the number within parentheses immediately after the "X" or "9". A character value with a width of 5 is specified as PIC XXXXX or PIC X(5).

The following table shows how the COBOL PICTURE and USAGE correspond to SAS informats. "Native system" indicates that the value is being read on the same system on which it was created. "Non-native system" indicates that the value is in IBM (mainframe) format and is being read on a different (non IBM) system.

                              NATIVE SYSTEM         NON-NATIVE SYSTEM
COBOL PICTURE                 INFORMAT              INFORMAT
-------------                 -------------         -----------------
PIC X(n)                      $w. or $CHARw.        $EBCDICw.

PIC 9(int)V9(fract)           w.d                   S370FF

PIC 9(int)V9(fract) COMP-3    PK or S370FPDU        PK or S370FPDU

PIC S9(int)V9(fract) COMP-3   PD                    S370FPD

PIC 9(int)V9(fract) DISPLAY   S370FZDU              S370FZDU

PIC S9(int)V9(fract) DISPLAY  ZD                    S370FZD

PIC S9(int)V9(fract) DISPLAY
 SIGN LEADING                 S370FZDL              S370FZDL

PIC S9(int)V9(fract) DISPLAY
 SIGN LEADING SEPARATE        S370FZDS              S370FZDS

PIC S9(int)V9(fract) DISPLAY
 SIGN TRAILING SEPARATE       S370FZDT              S370FZDT

PIC 9(int)V9(fract) COMP      S370FIBU              S370FIBU

PIC S9(int)V9(fract) COMP     IB or PIB             S370FIB or S370FPIB

no picture but usage COMP-1   RB4.                  S370FRB4.

no picture but usage COMP-2   RB8.                  S370FRB8. 

Notes:

  1. If the picture contains a signed numeric without a USAGE, then the USAGE type is DISPLAY.
  2. The PK and S370FPDU informats both read unsigned packed decimal. The difference is that PK reads values that do not contain a sign bit and S370FPDU reads IBM mainframe values which always contain an "F" as the sign in the right-most bit.
  3. The S370FIBU informat reads unsigned integer binary values stored in IBM mainframe format. The PIB informat reads positive integer binary values, treats all values as positive, and includes the sign bit as part of the value. The S370FPIB informat reads positive integer binary values stored in IBM mainframe format, treats all values as positive, and includes the sign bit as part of the value.

Use the following chart to determine the correct width and decimal specification to use with the SAS informat:

    USAGE                       WIDTH                     DECIMAL
   -----                       -----                     -------
   DISPLAY (Zoned Decimal)     (int+fract)               (fract)

   COMP-3 (Packed Decimal)     CEIL((int+fract+1)/2)     (fract)

   COMP (Integer Binary):
    if  1<=(int+fract)<=4      2                         (fract)
    if  5<=(int+fract)<=9      4                         (fract)
    if 10<=(int+fract)<=18     8                         (fract) 

Please reference SAS Note 56655, "SAS® formats that correspond to COBOL data descriptions", for further information about COBOL picture clauses and corresponding SAS formats.