In PHPM 672 this week, we are working with -label define-, -label variables-, and -label values- to label data. You can use these these (in combination with commands like -recode- and -replace-) to get a consistently labeled dataset, but there are three utilities that can get you there more efficiently: -encode-, -multencode-(from SSC), and a suite of utilities in -labutil-(from SSC).
The goal is to get to a common value assignment across all similar variables (example: many variables that use the same categorical scale of responses). You can simply use -encode- if you are sure that the string variables that you are using to build categorical variables with value labels all have the same categories that are all spelled the exact same way. If not, you will need to use -multencode- to deal with missing categories and -replace- or -subinstr()- to correct any spelling deviations. Finally, once you've labeled the categorical variables consistently, you want to put them in an order that makes sense (e.g., lowest to highest) using -labvalch-
Here's an example of this process with a sample dataset. Copy and paste this snippet into a do-file & run it to see how this process words: