Generating variable aliases and metadata
The following describes how to generate variable aliases and metadata based on input variable data.
Crunch Automation provides a handful of functions that operate on attributes of the input variables so that they can be used as attributes of the newly-generated variables:
- COPY(field_name)
- KEEP_AFTER(field_name, separator)
- KEEP_BEFORE(field_name, separator)
- KEEP_BETWEEN(field_name, start_separator, end_separator)
- PREFIX(field_name, prefix)
- REGEX_REPLACE(field_name, match, replacement)
- REMOVE_COMMON_PREFIX(field_name)
- REMOVE_COMMON_SUFFIX(field_name)
- SUFFIX(field_name, suffix)
For example:
CREATE CONVERT q_1...q_100 TO NUMERIC AS
REGEX_REPLACE(ALIAS, "^q_", "num_")
TITLE COPY(DESCRIPTION)
DESCRIPTION PREFIX(TITLE, "Numeric version of ")
NOTES REMOVE_COMMON_PREFIX(NOTES);