Survey Solutions helpfully names value labels to match variable labels. But when variables need to be renamed, that convenient coupling is broken.
While Stata provides a simple way to rename variables, there is no simple command to rename labels.
Implementation ideas
To rename value labels, there is no single command. Instead, one must do something like the following:
Copy the value labels from one label object to another one--that is, from the old value label name ot the new value label name
Drop the old value label object
Issue an error if the old value label object is applied to multiple variables
Some illustrative code for the underlying process:
* create some fake data
gen a = .
gen b = .
* create a value label for variable `a`
label define a 1 "foo" 2 "bar", modify
label values a a
* copy those labels from a to b
label copy a b
To make this operation simpler, create a single command that encapsulates the steps above (or a better algorithm).
Problem
Survey Solutions helpfully names value labels to match variable labels. But when variables need to be renamed, that convenient coupling is broken.
While Stata provides a simple way to rename variables, there is no simple command to rename labels.
Implementation ideas
To rename value labels, there is no single command. Instead, one must do something like the following:
Some illustrative code for the underlying process:
To make this operation simpler, create a single command that encapsulates the steps above (or a better algorithm).