Hi everyone,
I am currently working with panel data and can’t figure out how to relate variables from different years to each other.
The data comes from surveys in which the same participants got asked different questions each year. So this isn’t a typical time series where you have the same kind of data for each year. Each participant has a unique ID and each observation in the data set represents a single survey. If a question wasn’t asked that year, the observations has a missing for that variable.
So my Data looks somewhat like this:
….
What I would like to do is to relate the data from different years to each other. For example to show the results of opinion1 (“how strongly do you agree with …”) only for people who voted in the year prior (voted == 1).
Ideally that would work like this: tab opinion1 if voted == 1
But that of course doesn’t work because within the observation that holds the data for voted there is no data on opinion1.
How can I work around this? Do I have to somehow combine observations via their id or is there an easier way?
thanks in advance!
I am currently working with panel data and can’t figure out how to relate variables from different years to each other.
The data comes from surveys in which the same participants got asked different questions each year. So this isn’t a typical time series where you have the same kind of data for each year. Each participant has a unique ID and each observation in the data set represents a single survey. If a question wasn’t asked that year, the observations has a missing for that variable.
So my Data looks somewhat like this:
id | year | voted | opinion1 | opinion2 |
1 | 2018 | 1 | . | . |
1 | 2019 | . | 7 | . |
1 | 2020 | . | . | 2 |
2 | 2018 | 0 | . | . |
2 | 2019 | . | 7 | . |
What I would like to do is to relate the data from different years to each other. For example to show the results of opinion1 (“how strongly do you agree with …”) only for people who voted in the year prior (voted == 1).
Ideally that would work like this: tab opinion1 if voted == 1
But that of course doesn’t work because within the observation that holds the data for voted there is no data on opinion1.
How can I work around this? Do I have to somehow combine observations via their id or is there an easier way?
thanks in advance!
Comment