Hello. I am working on a database that has a variable called 'sector' (string) and another one called 'code_sector' (long). Using the codebook command, I check for the unique values in each variable, and I get that there are 52 unique values in sector and 30 unique values in code_sector.

So I think there are some misspellings in the sector variables. Next, I use bysort code_sector: replace sector = sector[1] to correct the misspellings by only keeping the first name of the sectors with the same code. So far so good. But, when I use codebook again, it says that there now are just 29 unique values in the variable sector! How is that possible? One thing is that when running codebook on sector, it says ' warning: variable has embedded blanks' (it is true, the names of the sectors have spaces, but I guess it should not cause problems with this).

Thanks in advance