Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename value label #9

Open
arthur-shaw opened this issue Dec 26, 2023 · 0 comments
Open

Rename value label #9

arthur-shaw opened this issue Dec 26, 2023 · 0 comments
Labels
value 🏷️ Value label

Comments

@arthur-shaw
Copy link
Contributor

arthur-shaw commented Dec 26, 2023

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:

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

@arthur-shaw arthur-shaw added the value 🏷️ Value label label Dec 26, 2023
@arthur-shaw arthur-shaw added this to the v1.1 milestone Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
value 🏷️ Value label
Projects
None yet
Development

No branches or pull requests

1 participant