Dear all,
I am trying to append several datasets which contain a large number of variables.
In some datasets, the value labels have the same name even though the underlying information is not the same.
Thus, I am looking for a way how to "rename" the value labels in one go such that afterwards I can append without problems.
In a previous thread (https://www.stata.com/statalist/arch.../msg00879.html), I found this code:
This is immensely helpful.
However, some of my value labels are called for example "A01.2". I suspect that the dot in the value label causes troubles, as the code above does not work in these cases.
Do you have any suggestions how to circumvent this problem and rename the value labels such that I can append the datasets (afterwards the manual work starts, but then at least I have all info already in one dataset and can use lookfor etc)
Thank you very much in advance!!
Best
I am trying to append several datasets which contain a large number of variables.
In some datasets, the value labels have the same name even though the underlying information is not the same.
Thus, I am looking for a way how to "rename" the value labels in one go such that afterwards I can append without problems.
In a previous thread (https://www.stata.com/statalist/arch.../msg00879.html), I found this code:
Code:
desc ds, has(vallabel) local vars `r(varlist)' foreach var of local vars { // get the name of the value label for variable `var' local labname : value label `var' // create a copy with name prefix + oldname label copy `labname' W1_`labname', replace // assign that copy to variable `var' label value `var' W1_`labname' } // see the new label names desc
However, some of my value labels are called for example "A01.2". I suspect that the dot in the value label causes troubles, as the code above does not work in these cases.
Do you have any suggestions how to circumvent this problem and rename the value labels such that I can append the datasets (afterwards the manual work starts, but then at least I have all info already in one dataset and can use lookfor etc)
Thank you very much in advance!!
Best
Comment