Dear Statalist,
I am trying to merge two datasets. More precisely I try to merge data from the European Social Survey (ESS) with some other data. However, I always get the error "variable *** already defined", where *** is one of the variables in the ESS dataset. This does not just affect one variable but multiple. First I got this error for the variable "dcsfwrk", so I just dropped that variable. Then I got the error for the variable "wrywprb", so I dropped that variable. Then I got the error for the variable "trdawrk". You get the idea.
The issue is, none of these variables is in the data I try to merge the ESS data with. In the other data are only 12 variables, so it is easy to keep an overview and I am very sure that none of the problematic variables is in there.
So I further investigated this issue and discovered that all of the problematic variables are three times in the ESS data. In the ESS data seem to be multiple variables with the exact same name and exactly the same content. However, these extra variables only show up if I search for the variable name using the search bar on the right (see the attached screenshot). The variables for example do not show up when I use Data Editor (Browse) to look at the data. Then the variable only shows up once. Other commands like for example tab also work normally with these variables. So
shows me the expected result.
This is the first time I have seen something like that and I am not sure what to do. As I said, this same error affects multiple variables. I also downloaded a fresh dataset from the ESS website and I have exactly the same issue again without modifying the data in any way. The ESS data I am working with can be downloaded here: https://www.europeansocialsurvey.org/downloadwizard/
Another strange thing is that I have to drop these variables three times in order to get rid of them. So I have to execute the code
three times to drop this variable completely. Each drop gets rid of one of the instances of dcsfwrk.
Here is also my merge code, although I do not believe that this is the issue.
This is my first post here so please let me know if I should format my post in a different way or if you need more information. Thank you so much for your help.
Best wishes,
Jasper

I am trying to merge two datasets. More precisely I try to merge data from the European Social Survey (ESS) with some other data. However, I always get the error "variable *** already defined", where *** is one of the variables in the ESS dataset. This does not just affect one variable but multiple. First I got this error for the variable "dcsfwrk", so I just dropped that variable. Then I got the error for the variable "wrywprb", so I dropped that variable. Then I got the error for the variable "trdawrk". You get the idea.
The issue is, none of these variables is in the data I try to merge the ESS data with. In the other data are only 12 variables, so it is easy to keep an overview and I am very sure that none of the problematic variables is in there.
So I further investigated this issue and discovered that all of the problematic variables are three times in the ESS data. In the ESS data seem to be multiple variables with the exact same name and exactly the same content. However, these extra variables only show up if I search for the variable name using the search bar on the right (see the attached screenshot). The variables for example do not show up when I use Data Editor (Browse) to look at the data. Then the variable only shows up once. Other commands like for example tab also work normally with these variables. So
Code:
tab dcsfwrk
This is the first time I have seen something like that and I am not sure what to do. As I said, this same error affects multiple variables. I also downloaded a fresh dataset from the ESS website and I have exactly the same issue again without modifying the data in any way. The ESS data I am working with can be downloaded here: https://www.europeansocialsurvey.org/downloadwizard/
Another strange thing is that I have to drop these variables three times in order to get rid of them. So I have to execute the code
Code:
drop dcsfwrk
Here is also my merge code, although I do not believe that this is the issue.
Code:
use "other_data", clear merge 1:m year cntry using "ess_data_positions.dta"
Best wishes,
Jasper
Comment