Package DDIwR uses numeric declared missing codes as its internal R
representation. Recoding to "Stata" or "SAS" is therefore best viewed as
an export-oriented temporary representation, not as a preferred internal
storage strategy for declared vectors in R.
SAS's ._ tag is retained separately as "_" in na_index when it is
absent from the recoding dictionary. Columns with missing metadata alone
are accepted, even without variable or value labels.
Recoding retains variable formats, widths, temporal classes and units, custom
SPSS attributes, Stata characteristics, the spss_metadata, stata_metadata
and sas_metadata lists, and dataset labels and notes. Labels and missing-value
definitions are updated to match the recoded values. Character-to-numeric
recoding clears obsolete string storage fields in these lists, as described
in recodeCharcat().
When no dictionary is provided, export-oriented recoding can be performed
either by scanning the entire dataset for a harmonized mapping, or by
recoding each variable independently. The package now defaults to the faster
per-variable strategy in export preparation. Supplying a dictionary keeps the
harmonized cross-dataset behavior.
When a dictionary is not provided, it is automatically constructed from the
available data and metadata, using negative numbers starting from -91 and up
to 27 letters starting with "a".
If the dataset contains mixed variables with SPSS and Stata style missing
values, unless otherwise specified in a dictionary it uses other codes than
the existing ones.
For the SPSS type of missing values, the resulting variables are coerced to a
declared labelled format.
Unlike SPSS, Stata does not allow labels for character values. Both cannot be
transported from SPSS to Stata, it is either one or another. If labels are
more important to preserve than original values (especially the information
about the missing values), the argument chartonum replaces all character
values with suitable, non-overlapping numbers and adjusts the labels
accordingly.
If no labels are found in the metadata, the original values are preserved.