For this function, a categorical variable is something else than a base
factor. It should be an object of class "declared" with a specific
attribute called "labels" that stores the value labels.
Variable labels, display widths, custom SPSS attributes and Stata
characteristics are retained. String formats and storage widths are removed
when the values become numeric; subsequent exports derive numeric formats.
The spss_metadata, stata_metadata and sas_metadata lists are also
retained, except for their string storage fields (format, width, SAS
informat and Stata type).