Skip to content

Diogo TravassosData leadership · Analytics · Decision-making

Real public data

Loan data conversion: which reconciliation catches the faults

On public SBA files, mapping statuses from the SBA's data dictionary left 74,600 loans with no status, and matching totals missed it. Check each converted loan against rules too.

Totals still matched, but the 7(a) charge-off rate read 3.22%, not 2.49%.

Loans charged off (written off as lost) per 7(a) loan paid out. Loans with no status drop out of the count.

  1. Mapped from the codes in the 7(a) file2.49%
  2. Mapped from the SBA data dictionary3.22%

Real public data: 523,243 SBA loan records, 45,597 Montana mortgage records for 2017 and the FDIC bank list, all federal public data.

Lenders moving loans onto a new system often sign off once record counts and amount totals match the old system's. This study converted 568,840 records into one loan table. They are loans from two Small Business Administration (SBA) programs, 7(a) and 504, and Montana mortgages. The SBA data dictionary spells paid in full PIF, but the 7(a) file writes P I F. A status map (source code to loan status) built from the dictionary left 74,600 loans with no status. A missing status changes neither a record count nor a dollar total, so the totals still matched. A rule check caught it: every converted loan must have a status.

What to do

Do not sign off a conversion on totals alone. They see only faults that change a count or a sum.

Before go-live, run three quick checks. These are the totals, 19 rules on the converted loans, and a check that every source code has a mapping.

Trace each rule failure on the first run to its source record before accepting it. A failure accepted unchecked catches nothing.

Make a rebuild part of the gate. A second engineer converts the data again from the rule document alone, and the two are compared loan by loan.

Have someone who did not write the code maps read 60 loans per source against the source. Even fully traced, five faults got past every automated check. Each mapped a code wrong in the rule document both builds read.

What it is worth

For illustration, assume a conversion carries 10 faults, and each one that reaches go-live costs US$50,000.

How I would put this to work with a team

  1. The conversion analyst writes the rule document first. A data engineer writes the SQL from it.
  2. A second engineer writes the rebuild from the same document, without reading the SQL.
  3. Loan operations owns the code maps and signs each mapping line and accepted rule failure. A credit risk analyst reads the 60 loans per source.
  4. The conversion lead holds the go-live gate. It opens when the quick checks show no unexplained break and the two versions match loan by loan.

The SQL

The conversion is one SQL script, sql/convert.sql, run in DuckDB. The totals, rules and code census are SQL queries too (tools/checks.py). Two pieces of the script follow, copied from the file.

De-duplication. A window function numbers rows that match in every source column. Python fills {ALL_COLS_7A} with the file's columns.

dup_7a AS (
  SELECT src_row, row_number() OVER (PARTITION BY {ALL_COLS_7A} ORDER BY src_row) > 1 AS exact_duplicate
  FROM raw_7a
),

On the 7(a) file it flagged 396 rows as repeats. They stay in the table, flagged.

The status join.

c7a AS (
  SELECT
    '7A-' || r.src_row AS loan_id,
    '7A' AS source_system,
    r.src_row AS source_row,
    'commercial' AS segment,
    'loan' AS record_kind,
    ms.status AS status,
  /* 26 lines cut */
  FROM raw_7a r
  JOIN dup_7a d USING (src_row)
  LEFT JOIN map_status ms ON ms.source = '7A' AND ms.code = r.LoanStatus
  LEFT JOIN map_revolver mr ON mr.source = '7A' AND mr.code = r.RevolverStatus
  LEFT JOIN map_rate_type mt ON mt.source = '7A' AND mt.code = r.FixedorVariableInterestInd
),

With the dictionary's map, P I F finds no match, so the left join leaves the status empty. The rule check SELECT count(*) FROM loan WHERE status IS NULL returned 74,600 on that build and 0 on the correct one.

What would change the conclusion

The tests: after each go-live, log every defect found, its fix cost, and whether it changed a count or a sum. The last line stays open: its test could cost more than the rebuild.

Limits

Every cost and saving figure is assumed and was chosen after the results. The checks' author wrote the fault list, and no source gives how often each kind occurs. Faults written blind by someone else are the next step.

The rebuild caught every code fault by construction: faults sat only in the main SQL. The cost figures assume it always would.

The code census was built for this mismatch and caught none of the random faults.

Faults ran one at a time. The cost figures assume two never hide each other in totals.

The P I F mismatch was seen in a code count before the design, then run as a planted fault. How each check treated it follows from how the check works.

The plan written before the runs kept the rebuild out of the gate unless traced quick checks missed over 1 in 10 charge-off faults. They missed 1 of 15, too few to settle that line, so the rebuild joined the gate after the results.

No tracing was tested, so traced figures are an upper bound. The split by fault kind, the untraced figures and reading the 80% line on real defects were added after the results.

The 60-loan read assumes a reader who knows the correct rules. Putting it in the gate was added after the results.

The source files carry no balances, payments or days past due, and the mortgage records are one state in one year.

No source carries a loan number, so two identical rows may be two loans.

Two of eight conversion predictions and both lender-matching predictions missed.

More limits are on the method page.

Detail pages