Thanks in advance for suggestions. I want to change the format of the data (I think the correct terminology is to go from wide format to long format).
I have a dataset that looks like this:
countrycode | year | discrimination_Christianity | discrimination_Judaism | discrimination_Islam |
1 | 2000 | 0 | 0 | 1 |
1 | 2001 | 0 | 1 | 1 |
2 | 2000 | 1 | 1 | 0 |
2 | 2001 | 1 | 1 | 0 |
I can replace with one column called discrimination. And then I would add religious groups as rows for each country-year like the following:
countrycode | year | religiousgroup | discrimination |
1 | 2000 | Christianity | 0 |
1 | 2000 | Judaism | 0 |
1 | 2000 | Islam | 1 |
1 | 2001 | Christianity | 0 |
1 | 2001 | Judaism | 1 |
1 | 2001 | Islam | 1 |
2 | 2000 | Christianity | 1 |
2 | 2000 | Judaism | 1 |
2 | 2000 | Islam | 0 |
2 | 2001 | Christianity | 1 |
2 | 2001 | Judaism | 1 |
2 | 2001 | Islam | 0 |
This is the code I have so far:
reshape long discrimination, i(countrycode) j(year) k(religiousgroup)
will this work?
Thank you,
Daniel
0 Response to Converting a country-year dataset into a countyr-year-religiousgroup dataset (from wide format to long format)
Post a Comment