lsms-worldbank / labeller

Spot and fix common problems with variable and value labels🏷
https://lsms-worldbank.github.io/labeller/
0 stars 0 forks source link

Rename value label #9

Open arthur-shaw opened 11 months ago

arthur-shaw commented 11 months ago

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:

* 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).