Previous Topic: 7.3.2.1.2 Define Input Record Validation (USRFMT2)

Next Topic: 7.3.2.1.4 Define Additional Process Code (USRFMT4-6)

7.3.2.1.3 Define Input/Output Processing (USRFMT3)

Use the USRFMT3 macro to read fields from the input data,
validate each input field, and format these fields (data
elements) according to the needs of your field developed
application.  Thereafter, build output file observations
and direct the writing of output files.

Consider the following items and code your routine
appropriately:

  o Validate all data that you input.  Use either standard or
    user-defined SAS INFORMATs to validate input data fields,
    or use logic in your USRFMT3 macro.  The following are
    some areas to examine:

      - impossibly high or low values
      - unexpected negative numbers
      - check the data against a list of permissible values

  o Remember to use a trailing "@" (at sign) on INPUT
    statements that will be followed by a subsequent INPUT
    statement.

  o Create output file data elements from input record fields
    and other processing decisions.

    The values of calculated data elements (elements whose
    TYPE statement is XC, C, or a variation) are calculated
    through the %fffDERV macro.  The file's data element
    calculation macro is invoked by the format routine shell
    code directly before the file's constructed observation
    is output, so the code you write in USRFMT3 does not need
    to duplicate these operations.

  o Some input record processing may require you to read a
    subtype field in the front of the input record and then
    branch to a particular logic subroutine based on the
    subtype value.

  o If your input records have a segmented structure such
    that a single input record will result in multiple
    observations in the database, use USRFMT2 to decode the
    common information from the record (including ENDTS and
    ORGSYSID) and use USRFMT3 to decode each segment.  Use
    the SAS LINK statement to branch to the output processing
    subroutine OUTfff in DYfdaFMT and then return to input
    the next segment.  This is described in more detail below.

  o Further in the USRFMT3 logic, if it is determined that
    the current input record will not contribute to ANY FDA
    output file, this decision must be handled by branching
    to label OPTN_DEL so that this record is counted as
    'option deleted'.

  o Input records whose length is not sufficient for the
    INPUT process that follows may be encountered.  Logic in
    USRFMT3 may need to validate the (remaining) input record
    length more than once.

    When USRFMT3 determines that the current input record is
    not the expected length or not long enough, branch to
    label SHORTREC so that this record is counted as 'short
    record deleted'.

At some point, USRFMT3 will reach an output decision point.
One observation suitable for output to one or more work files
has been built.  Its timestamp has been found to allow it
into the database based on checkpointing algorithms, and the
record's data elements have been filled in.  The output
branch logic is now referenced.

DYfdaFMT's shell includes code generated from the following
template:

  OUTfff:
     IF &fffSFD THEN DO;
       %fffDERV;
       /* USER COSTING AND MANIPULATION EXIT */
       %FXIT(NAME=USRSfff);
       OUTPUT WORK.iiifff00;
     END;
     RETURN;

DYfdaFMT contains one of these routines for each file that
appears in its main DATA step.  To write an observation to a
file, this routine must be referenced by the code in USRFMT3.
Choose one of the following methods to reference this code:

  o Link to it if you have further processing to perform on
    the input record.  If you have segmented records and each
    segment will be an output observation or if you will be
    building two different records in the database for each
    input record, linking is the best technique to use.  The
    statement format is as follows:

      LINK OUTfff;

  o Branch to it if no further processing is to be done on
    the current input record.  This will cause the
    observation that you have built to be put to a work
    file and the format routine to return for another record.
    The statement format is as follows:

      GOTO OUTfff;

Two equivalent USRFMT3 macros to illustrate this follow:

  %MACRO USRFMT3;
    detailed processing
    IF condition-favorable THEN LINK OUTfff;
    ELSE GOTO OPTN_DEL;
  %MEND USRFMT3;

  %MACRO USRFMT3;
    detailed processing
    IF condition-unfavorable THEN GOTO OPTN_DEL;
  %MEND USRFMT3;

Remember, if you choose not to use an input record to build
an observation in your database, code GOTO OPTN_DEL.
OPTN_DEL adjusts the input records processed count for the
audit trail and causes the format routine to get the next
input record, if any.