CODESCAN: Stata module to scan wide-format code variables for pattern matches
Timothy P Copeland ()
Additional contact information
Timothy P Copeland: Karolinska Institutet
Statistical Software Components from Boston College Department of Economics
Abstract:
codescan scans wide-format code variables, such as dx1-dx30 or proc1-proc20 in registry and claims data, for pattern matches using regular expressions or prefix matching, with rules given inline or read from a reusable CSV or Stata code dictionary. It creates binary indicators or per-row counts for each defined condition, supports exclusion patterns, applies lookback and lookforward time windows around a reference date, reports prevalence, and can collapse to patient-level summaries or merge them back onto the rows. Results are returned in r() and can be placed in a named frame, saved as a dataset, or exported to CSV or Excel. Diagnostics include per-variable contributions, pairwise co-occurrence, and multi-window sensitivity with denominators. The companion command codescan_describe inventories the code values in the same variables before any rules are written and can draft a starter codefile. It works with ICD, KVA, CPT, ATC, OPCS, or any string code system.
Language: Stata
Requires: Stata version 16
Keywords: ICD codes; diagnosis codes; procedure codes; drug codes; registry data; claims data; pattern matching; regular expressions; comorbidity; code lists (search for similar items in EconPapers)
Date: 2026-10-30
Note: This module should be installed from within Stata by typing "ssc install codescan". The module is made available under terms of the MIT license (https://opensource.org/licenses/MIT).
References: Add references at CitEc
Citations:
Downloads: (external link)
http://fmwww.bc.edu/repec/bocode/c/codescan.ado program code (text/plain)
http://fmwww.bc.edu/repec/bocode/_/_codescan_engine.ado program code (text/plain)
http://fmwww.bc.edu/repec/bocode/_/_codescan_codefile.ado program code (text/plain)
http://fmwww.bc.edu/repec/bocode/_/_codescan_definitions.ado program code (text/plain)
http://fmwww.bc.edu/repec/bocode/_/_codescan_outputs.ado program code (text/plain)
http://fmwww.bc.edu/repec/bocode/_/_codescan_parse_filespec.ado program code (text/plain)
http://fmwww.bc.edu/repec/bocode/_/_codescan_validate_path.ado program code (text/plain)
http://fmwww.bc.edu/repec/bocode/_/_codescan_tostring.ado program code (text/plain)
http://fmwww.bc.edu/repec/bocode/c/codescan.sthlp help file (text/plain)
http://fmwww.bc.edu/repec/bocode/c/codescan_describe.ado program code (text/plain)
http://fmwww.bc.edu/repec/bocode/c/codescan_describe.sthlp help file (text/plain)
Related works:
This item may be available elsewhere in EconPapers: Search for items with the same title.
Export reference: BibTeX
RIS (EndNote, ProCite, RefMan)
HTML/Text
Persistent link: https://EconPapers.repec.org/RePEc:boc:bocode:s459958
Ordering information: This software item can be ordered from
http://repec.org/docs/ssc.php
Access Statistics for this software item
More software in Statistical Software Components from Boston College Department of Economics Boston College, 140 Commonwealth Avenue, Chestnut Hill MA 02467 USA. Contact information at EDIRC.
Bibliographic data for series maintained by Christopher F Baum ().