Convert between the canonical clean EIN (`ein`, e.g. `"04-2104327"`) published by all new NCCS products and the legacy / NODC join key (`EIN2`, e.g. `"EIN-04-2104327"`) used by harmonized CORE marts, the Unified BMF, and NODC `efile_v2_1`. The two carry identical information: `EIN2` is exactly `ein` with a literal `EIN-` prepended, so the bridge is a deterministic string reformat with no lookup table (`nccs-contracts/conventions/ein-format.md`).
Value
A character vector the same length as the input: `nccs_ein_to_ein2()` returns `EIN-XX-XXXXXXX`, `nccs_ein2_to_ein()` returns `XX-XXXXXXX`, with `NA_character_` for un-normalizable elements.
Details
Both functions route every input through the canonical 9-digit-core normalization (strip non-digits, reject more than nine digits, left-zero-pad to nine, reject the all-zeros placeholder), so they also recover EINs that lost a leading zero on a bare-integer surface (`"42104327"` -> `"04-2104327"`).
These helpers are **lenient**: an input that cannot be normalized becomes `NA`, and the call emits a `warning()` reporting how many non-empty inputs were dropped, so silent loss stays visible. EINs are handled as character end to end; never pass numeric storage, which is what drops leading zeros.
The round-trip is lossless: `nccs_ein2_to_ein(nccs_ein_to_ein2(e))` returns `e` for every valid `ein`, and the reverse for every valid `EIN2`.
Examples
nccs_ein_to_ein2("04-2104327") # "EIN-04-2104327"
#> [1] "EIN-04-2104327"
nccs_ein2_to_ein("EIN-04-2104327") # "04-2104327"
#> [1] "04-2104327"
# Leading zeros are preserved through the bridge.
nccs_ein2_to_ein("EIN-00-0000004") # "00-0000004"
#> [1] "00-0000004"
# Lossless round-trip.
nccs_ein2_to_ein(nccs_ein_to_ein2("36-3686904")) # "36-3686904"
#> [1] "36-3686904"