I'm working with this type of data set in Stata:
Year | Country | Investment | Value |
---|---|---|---|
2000 | US | Bonds Total | 8% |
2000 | US | Bonds Private | 50% |
2000 | US | Equity Total | 10% |
2000 | US | Bonds Public | 50% |
2000 | US | Equity listed | 30% |
2000 | US | Equity Unlisted | 70% |
2000 | FR | Bonds Total | 5% |
2000 | FR | Bonds Private | 40% |
2000 | FR | Bonds Public | 60% |
2001 | US | Bonds Private | 70% |
My issue is that "Bonds Private" and "Bonds Public" are subcategories of "Bonds Total". For my analysis, I would need to have those data in the same line as their respective category.
Thus, I'm trying to achieve this:
Year | Country | Bonds Total | Bonds Private | Bonds Public | Equity Total | Equity Listed | Equity Unlisted | Real Estate | etc.. |
---|---|---|---|---|---|---|---|---|---|
2000 | US | 8% | 50% | 50% | 10% | 30% | 70% | 5% | ... |
2000 | FR | 5% | 60% | 40% | 12% | 10% | 90% | 8% | ... |
2000 | DE | 6% | 40% | 60% | 15% | 10% | 90% | 10% | ... |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2019 | CA | 5% | 60% | 40% | 10% | 30% | 70% | 10% | ... |
I already tried to achieve this by using the function reshape
but I could not achieve the same result. Here is what I have tried :
by Year Country, sort: gen newid = _n
reshape wide investment, i(year) j(newid)
I'm receiving the following error message:
values of variable newid not unique within year