I will try to explain my issue as good as I possibly can. However, I am by no means an expert. Therefore, I was hoping some of you experts out there could help in resolving my issue.
I have a dataset which consists of a survey with approx. 5.000 observations/respondents. Each respondent is linked to his/her corresponding municipality. In total, there are 91 municipalities and each respondent has been assigned to his/her municipality. I have added a new variable, population density, to my dataset. This variable shows the population density of each municipality at the given year 2013. However, this variable only contains 91 observations (one for each municipality) but it uses the same ID as my other dataset even though it only has one observation from each.
Now my question is how do I make it so that my new variable, population density, matches my other variable in terms of observations? I have a unique identifier for each municipality but multiple observation from each. So I basically want it to match the number of observations from each municipality.
I have one variable which contains the unique ID/number of the municipality for each respondent. There are multiple respondents from the same municipality.
For example:
Municipality ID | Gender | Municipality ID Population density (for each municipalty)
101 M 101 1.776
101 M 104 564
101 F
104 M
104 F
…. ….. (approx 5.000 obs. in total) ….. (only 91 obs. in total - one for each municipality)
Is there any smart way to do this other than having to do it manually? Like repeat the population density for municipality 101 for each observation from that given municipality.
Your help is much appreciated.
I have a dataset which consists of a survey with approx. 5.000 observations/respondents. Each respondent is linked to his/her corresponding municipality. In total, there are 91 municipalities and each respondent has been assigned to his/her municipality. I have added a new variable, population density, to my dataset. This variable shows the population density of each municipality at the given year 2013. However, this variable only contains 91 observations (one for each municipality) but it uses the same ID as my other dataset even though it only has one observation from each.
Now my question is how do I make it so that my new variable, population density, matches my other variable in terms of observations? I have a unique identifier for each municipality but multiple observation from each. So I basically want it to match the number of observations from each municipality.
I have one variable which contains the unique ID/number of the municipality for each respondent. There are multiple respondents from the same municipality.
For example:
Municipality ID | Gender | Municipality ID Population density (for each municipalty)
101 M 101 1.776
101 M 104 564
101 F
104 M
104 F
…. ….. (approx 5.000 obs. in total) ….. (only 91 obs. in total - one for each municipality)
Is there any smart way to do this other than having to do it manually? Like repeat the population density for municipality 101 for each observation from that given municipality.
Your help is much appreciated.
Comment